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

invalid offense Style/HashEachMethods #12761

Closed
thyresias opened this issue Mar 8, 2024 · 0 comments · Fixed by #12762
Closed

invalid offense Style/HashEachMethods #12761

thyresias opened this issue Mar 8, 2024 · 0 comments · Fixed by #12762
Labels

Comments

@thyresias
Copy link

Expected behavior

No offense.

Actual behavior

ruby_install.rb:128:5: C: [Correctable] Style/HashEachMethods: Use each_value instead of each and remove the unused _ block argument.
    news_history.chunk { |f| f[/(?<=NEWS-)./] }.each do |_, list| ...
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Steps to reproduce the problem

news_history.chunk { |f| f[/(?<=NEWS-)./] }.each do |_, list|
end

chunk does not return a Hash:

Each element in the returned enumerator is a 2-element array

RuboCop version

$ rubocop -V
1.62.0 (using Parser 3.3.0.5, rubocop-ast 1.31.1, running on ruby 3.3.0) [x64-mingw-ucrt]
@koic koic added the bug label Mar 8, 2024
koic added a commit to koic/rubocop that referenced this issue Mar 8, 2024
Fixes rubocop#12761.

This PR fixes a false positive for `Style/HashEachMethods`
when the key block argument of `Enumerable#each` method is unused after `chunk`.
bbatsov pushed a commit that referenced this issue Mar 8, 2024
Fixes #12761.

This PR fixes a false positive for `Style/HashEachMethods`
when the key block argument of `Enumerable#each` method is unused after `chunk`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants