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
Given the code:
records.each(&:lock!).each do |record| end
Style/RedundantEach says "Remove redundant each" on the first each.
Style/RedundantEach
each
Note that this passes the cop:
records.each { |record| record.lock! }.each do |record| end
So it's only when there is a block-pass that it ignores that there is an actual block implementation.
No offences
test.rb:2:8: C: [Corrected] Style/RedundantEach: Remove redundant each. records.each(&:lock!).each do |record| ^^^^^
It's gets corrected to:
records(&:lock!).each do |record| end
rubocop -V 1.38.0 (using Parser 3.1.2.1, rubocop-ast 1.23.0, running on ruby 3.1.2) [arm64-darwin21]
The text was updated successfully, but these errors were encountered:
I noticed the same with two symbols: threads.each(&:kill).each(&:join), so the last doesn't need to be a block.
threads.each(&:kill).each(&:join)
Sorry, something went wrong.
[Fix rubocop#11137] Fix a false positive for Style/RedundantEach wh…
2dbfbd2
…en using `each` with a symbol proc argument Fix: rubocop#11137
Merge pull request #11138 from ydah/fix_redundant_each
848b280
[Fix #11137] Fix a false positive for `Style/RedundantEach` when using `each` with a symbol proc argument
Successfully merging a pull request may close this issue.
Given the code:
Style/RedundantEach
says "Remove redundant each" on the firsteach
.Note that this passes the cop:
So it's only when there is a block-pass that it ignores that there is an actual block implementation.
Expected behavior
No offences
Actual behavior
It's gets corrected to:
RuboCop version
The text was updated successfully, but these errors were encountered: