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

An error while running Performance/RedundantMerge cop #3006

Closed
eyusupov opened this issue Apr 5, 2016 · 0 comments
Closed

An error while running Performance/RedundantMerge cop #3006

eyusupov opened this issue Apr 5, 2016 · 0 comments

Comments

@eyusupov
Copy link

eyusupov commented Apr 5, 2016

When running RuboCop on the sample code attached below, Performance/RedundantMerge cop is failing.

Expected behavior

RuboCop checks the code correctly.

Actual behavior

The following error is shown (when running with -d option):

An error occurred while Performance/RedundantMerge cop was inspecting /home/eyusupov/toptal/toptal/1.rb.
undefined method `name' for #<Parser::Source::Map::Send:0x005605c56b9bc8>
/home/eyusupov/sources/rubocop/lib/rubocop/cop/performance/redundant_merge.rb:31:in `block in on_send'
/home/eyusupov/sources/rubocop/lib/rubocop/cop/performance/redundant_merge.rb:19:in `redundant_merge'
/home/eyusupov/sources/rubocop/lib/rubocop/cop/performance/redundant_merge.rb:25:in `on_send'
/home/eyusupov/sources/rubocop/lib/rubocop/cop/commissioner.rb:42:in `block (2 levels) in on_send'

Steps to reproduce the problem

Create a Ruby file with the following code:

t.each_with_object({}) { |_, r| r[:a].merge!(a: '') }

Run RuboCop on this file.

RuboCop version

$ ./bin/rubocop -V
0.39.0 (using Parser 2.3.0.7, running on ruby 2.2.4 x86_64-linux)
lumeet added a commit to lumeet/rubocop that referenced this issue Apr 8, 2016
Make sure the receiver for `merge!` inside `each_with_object` is a
local variable. This prevents the following from crashing:

    t.each_with_object({}) { |_, r| r[:a].merge!(a: '') }
@bbatsov bbatsov closed this as completed in 6d6a895 Apr 9, 2016
rrosenblum added a commit to rrosenblum/rubocop that referenced this issue Apr 13, 2016
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Oct 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant