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

False positive in Style/HashEachMethods u #12540

Closed
gaffneyc opened this issue Dec 14, 2023 · 0 comments · Fixed by #12543
Closed

False positive in Style/HashEachMethods u #12540

gaffneyc opened this issue Dec 14, 2023 · 0 comments · Fixed by #12543
Labels

Comments

@gaffneyc
Copy link

Actual behavior

Rubocop is claiming that *args is unused even though it is used to expand arguments passed to Tag.new.

Tag = Struct.new(:label, :missing, :healthy)

tags = []
rows = [[ "tag", 1, 2 ]]

rows.each do |label, *args|
  tags << Tag.new(label, *args)
end
each.rb:6:1: C: [Correctable] Style/HashEachMethods: Use each_key instead of each and remove the unused *args block argument.
rows.each do |label, *args| ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^

RuboCop version

$ [bundle exec] rubocop -V
1.59.0 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.2.2) [arm64-darwin22]
  - rubocop-performance 1.19.1
  - rubocop-rails 2.22.2
@koic koic added the bug label Dec 15, 2023
koic added a commit to koic/rubocop that referenced this issue Dec 15, 2023
Fixes rubocop#12540.

This PR fixes false positives for `Style/HashEachMethods`
when rest block argument of `Enumerable#each` method is used.
koic added a commit that referenced this issue Dec 15, 2023
…h_each_methods

[Fix #12540] Fix false positives for `Style/HashEachMethods`
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