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

Add autocorrection for Style/EachWithObject #3306

Merged
merged 1 commit into from
Jul 11, 2016

Conversation

owst
Copy link
Contributor

@owst owst commented Jul 9, 2016

Simple change to add autocorrection for Style/EachWithObject.


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).
  • Used the same coding conventions as the rest of the project.
  • 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.
  • All tests are passing.
  • The new code doesn't generate RuboCop offenses.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.

@owst owst force-pushed the add_autocorrect_for_each_with_object branch from 1d3aa33 to 73ae183 Compare July 9, 2016 18:06
@@ -33,7 +33,17 @@ def on_block(node)
return unless first_argument_returned?(args, return_value)
return if accumulator_param_assigned_to?(body, args)

add_offense(method, :selector, format(MSG, method_name))
add_offense(node, method.loc.selector, format(MSG, method_name))
Copy link
Contributor Author

@owst owst Jul 9, 2016

Choose a reason for hiding this comment

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

This was necessary so that the whole node is passed to the autocorrect method, giving us access to the block parameters (so that they can be reordered). The source highlighted for offenses is exactly the same as before.

@bbatsov bbatsov merged commit 18c2c5c into rubocop:master Jul 11, 2016
@bbatsov
Copy link
Collaborator

bbatsov commented Jul 11, 2016

Looks good!

Neodelf pushed a commit to Neodelf/rubocop that referenced this pull request Oct 15, 2016
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.

2 participants