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

UselessSetterCall bug? #574

Closed
lenntt opened this issue Oct 18, 2013 · 7 comments · Fixed by #586
Closed

UselessSetterCall bug? #574

lenntt opened this issue Oct 18, 2013 · 7 comments · Fixed by #586
Assignees

Comments

@lenntt
Copy link

lenntt commented Oct 18, 2013

Hi,
Im getting the following error:

1 error occurred:
An error occurred while UselessSetterCall cop was inspecting        .../...._controller_decorator.rb.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
Mention the following information in the issue report:
0.14.1 (using Parser 2.0.0, running on ruby 2.0.0 x86_64-linux)

Removing the following line from my code, removes the error:

some_name = @some_object.some_list.last

even changing the name 'some_name', seems to 'fix' the error,
while 'some_name' is being used a local variable, not an explicit method or accessor. So its hard to tell what is going on.

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 19, 2013

I guess @yujinakayama will have a look at this soon.

@yujinakayama
Copy link
Collaborator

Sure, I'll take a look.

@Confusion
Copy link

Partial stacktrace:

An error occurred while UselessSetterCall cop was inspecting something.rb.
undefined local variable or method `table' for #<Rubocop::Cop::Lint::UselessSetterCall::MethodVariableTracker:0x000000033525c0>
vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:122:in `block in process_multiple_assignment'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:113:in `each'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:113:in `each_with_index'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:113:in `process_multiple_assignment'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:85:in `block in contain_object_passed_as_argument?'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:101:in `block in scan'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:100:in `catch'
vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:100:in `scan'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:105:in `block (2 levels) in scan'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:103:in `each'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:103:in `block in scan'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:100:in `catch'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:100:in `scan'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:82:in `contain_object_passed_as_argument?'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:49:in `check_for_useless_assignment'
/vendor/bundle/ruby/2.0.0/gems/rubocop-0.14.1/lib/rubocop/cop/lint/useless_setter_call.rb:22:in `on_def'

@yujinakayama
Copy link
Collaborator

@SirLenz0rlot Can you share all lines of the method? I cannot reproduce the issue only with the snippet some_name = @some_object.some_list.last.

@sullerandras
Copy link

I have the same error message and stack trace for one of my classes. I'm not allowed to share the problematic code.
0.14.1 (using Parser 2.0.0, running on ruby 2.0.0 x86_64-darwin11.4.2)

However, it seems easy to fix, just a missing @ in cop/lint/useless_setter_call.rb:122
table[lhs_variable_name] = false
should be
@table[lhs_variable_name] = false

@yujinakayama
Copy link
Collaborator

@sullerandras Yeah, I've reproduced the error reported by @Confusion and already fixed in my local environment.
It occurs with multiple-assignement with non-array right hand side (e.g. a, b = do_something).

However I guess the issue reported by @SirLenz0rlot seems to be another one, since the report and the workaround are not related to multiple-assignment.

@lenntt
Copy link
Author

lenntt commented Oct 25, 2013

@yujinakayama
Sorry I couldnt pick an example to exactly to reproduce the error. Unfortunately, I cannot share all the lines of the method.
The error-causing line does not contain multiple-assignment, but I'm getting the exact same stacktrace as @Confusion

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

Successfully merging a pull request may close this issue.

5 participants