Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support autocorrection for Lint/AmbiguousOperator #7918

Merged

Conversation

koic
Copy link
Member

@koic koic commented Apr 29, 2020

This PR supports autocorrection for Lint/AmbiguousOperator.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@koic koic force-pushed the support_autocorrect_for_ambiguous_operator branch from fc22427 to e2ae212 Compare May 1, 2020 08:38
Copy link
Collaborator

@jonas054 jonas054 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I found a couple of minor things.

return offense_node if offense_node
end

processed_source.ast.each_node(:send).find do |send_node|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the local variable ast here.

context 'with parentheses around the operator' do
it 'does not register an offense' do
expect_no_offenses(<<~RUBY)
do_something(-42)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be +42 since the example is within the context "with + unary operator in the first argument".

@koic koic force-pushed the support_autocorrect_for_ambiguous_operator branch from e2ae212 to bc65f33 Compare May 1, 2020 10:56
@koic
Copy link
Member Author

koic commented May 1, 2020

Thanks for your review! I updated this PR.

This PR supports autocorrection for `Lint/AmbiguousOperator`.
@koic koic force-pushed the support_autocorrect_for_ambiguous_operator branch from bc65f33 to 1acc2ac Compare May 1, 2020 13:21
@koic koic merged commit 4f3cb38 into rubocop:master May 1, 2020
@koic koic deleted the support_autocorrect_for_ambiguous_operator branch May 1, 2020 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants