We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
a = [1] b = [2] c = [3] for n in a + b + c puts n end
Outputs:
1 2 3
Running rubocop -A on this method:
rubocop -A
style_for_test.rb:5:1: C: [Corrected] Style/For: Prefer each over for. for n in a + b + c ... ^^^^^^^^^^^^^^^^^^
File becomes:
a = [1] b = [2] c = [3] a + b + c.each do |n| puts n end
3
Output has changed!
Expected correction:
a = [1] b = [2] c = [3] (a + b + c).each do |n| puts n end
Which retains the original output.
rubocop -V:
rubocop -V
1.29.1 (using Parser 3.1.2.0, rubocop-ast 1.18.0, running on ruby 2.7.6 x86_64-linux) - rubocop-minitest 0.17.2 - rubocop-performance 1.13.2 - rubocop-rails 2.13.2
The text was updated successfully, but these errors were encountered:
I'll attempt to fix this.
Sorry, something went wrong.
Style/For
[Fix rubocop#10651] Fix autocorrect for Style/For when using array …
411a704
…with operator methods as collection Update lib/rubocop/cop/correctors/for_to_each_corrector.rb Co-authored-by: Koichi ITO <koic.ito@gmail.com> Remove unnecessary methods
Merge pull request #10654 from nobuyo/fix-autocorrect-for-style-for
2ac39af
[Fix #10651] Fix autocorrect for `Style/For` when using array with operator methods as collection
Successfully merging a pull request may close this issue.
Outputs:
Running
rubocop -A
on this method:File becomes:
Outputs:
Output has changed!
Expected correction:
Which retains the original output.
rubocop -V
:The text was updated successfully, but these errors were encountered: