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

Error in Style/CollectionCompact #11104

Closed
jcoyne opened this issue Oct 21, 2022 · 3 comments · Fixed by #11106
Closed

Error in Style/CollectionCompact #11104

jcoyne opened this issue Oct 21, 2022 · 3 comments · Fixed by #11106
Labels

Comments

@jcoyne
Copy link

jcoyne commented Oct 21, 2022

1 error occurred:
An error occurred while Style/CollectionCompact cop was inspecting /Users/jcoyne85/workspace/projectblacklight/blacklight/lib/blacklight/parameters.rb:10:6.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues

Mention the following information in the issue report:
1.37.0 (using Parser 3.1.2.1, rubocop-ast 1.23.0, running on ruby 3.1.2) [x86_64-darwin21]

The debug log says

An error occurred while Style/CollectionCompact cop was inspecting /Users/jcoyne85/workspace/projectblacklight/blacklight/lib/blacklight/parameters.rb:10:6.
undefined method `method_name' for s(:lvar, :params):RuboCop::AST::Node

          TO_ENUM_METHODS.include?(node.children.first.method_name)
                                                      ^^^^^^^^^^^^
Did you mean?  method
@koic
Copy link
Member

koic commented Oct 21, 2022

Can you provide reproduction code for this issue?

@jcoyne
Copy link
Author

jcoyne commented Oct 21, 2022

Yes

# foo.rb
class Foo
    def self.sanitize params
      params.reject { |_k, v| v.nil? }
    end
end
bundle exec rubocop foo.rb --only Style/CollectionCompact

@koic
Copy link
Member

koic commented Oct 22, 2022

I can reproduce it and opened #11106. Thank you!

koic added a commit to koic/rubocop that referenced this issue Oct 22, 2022
Fixes rubocop#11104.

This PR fixes an error for `Style/CollectionCompact`
when using `reject` method and receiver is a variable.
bbatsov pushed a commit that referenced this issue Oct 22, 2022
Fixes #11104.

This PR fixes an error for `Style/CollectionCompact`
when using `reject` method and receiver is a variable.
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