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

UselessAssignment cop chokes on ||= in argument list #707

Closed
sds opened this issue Dec 31, 2013 · 2 comments
Closed

UselessAssignment cop chokes on ||= in argument list #707

sds opened this issue Dec 31, 2013 · 2 comments

Comments

@sds
Copy link
Contributor

sds commented Dec 31, 2013

The following is valid ruby (e.g. ruby -c test.rb returns "Syntax OK").

function(foo ||= :bar)

Running Rubocop's master branch (07279a1) against this using rubocop -d test.rb results in the following:

Inspecting 1 file
Scanning /home/user/some-project/test.rb
For /home/user/some-project: configuration from /home/user/.rubocop.yml
Default configuration from /home/user/rubocop/config/default.yml
Inheriting configuration from /home/user/rubocop/config/enabled.yml
Inheriting configuration from /home/user/rubocop/config/disabled.yml
An error occurred while UselessAssignment cop was inspecting /home/user/some-project/test.rb.
undefined method `type' for nil:NilClass
/home/user/rubocop/lib/rubocop/cop/lint/useless_assignment.rb:72:in `return_value_node_of_scope'
/home/user/rubocop/lib/rubocop/cop/lint/useless_assignment.rb:58:in `message_for_useless_assignment'
/home/user/rubocop/lib/rubocop/cop/lint/useless_assignment.rb:37:in `block in check_for_unused_assignments'
/home/user/rubocop/lib/rubocop/cop/lint/useless_assignment.rb:34:in `each'
/home/user/rubocop/lib/rubocop/cop/lint/useless_assignment.rb:34:in `check_for_unused_assignments'
/home/user/rubocop/lib/rubocop/cop/lint/useless_assignment.rb:26:in `block in after_leaving_scope'
/home/user/rubocop/lib/rubocop/cop/lint/useless_assignment.rb:25:in `each_value'
/home/user/rubocop/lib/rubocop/cop/lint/useless_assignment.rb:25:in `after_leaving_scope'
/home/user/rubocop/lib/rubocop/cop/variable_inspector/variable_table.rb:17:in `invoke_hook'
/home/user/rubocop/lib/rubocop/cop/variable_inspector/variable_table.rb:36:in `pop_scope'
/home/user/rubocop/lib/rubocop/cop/variable_inspector.rb:65:in `inspect_variables_in_scope'
/home/user/rubocop/lib/rubocop/cop/variable_inspector.rb:58:in `inspect_variables'
/home/user/rubocop/lib/rubocop/cop/lint/useless_assignment.rb:21:in `investigate'
/home/user/rubocop/lib/rubocop/cop/commissioner.rb:94:in `block (2 levels) in invoke_cops_callback'
/home/user/rubocop/lib/rubocop/cop/commissioner.rb:100:in `with_cop_error_handling'
/home/user/rubocop/lib/rubocop/cop/commissioner.rb:93:in `block in invoke_cops_callback'
/home/user/rubocop/lib/rubocop/cop/commissioner.rb:85:in `each'
/home/user/rubocop/lib/rubocop/cop/commissioner.rb:85:in `invoke_cops_callback'
/home/user/rubocop/lib/rubocop/cop/commissioner.rb:55:in `investigate'
/home/user/rubocop/lib/rubocop/cop/team.rb:42:in `inspect_file'
/home/user/rubocop/lib/rubocop/file_inspector.rb:55:in `inspect_file'
/home/user/rubocop/lib/rubocop/file_inspector.rb:27:in `block in process_files'
/home/user/rubocop/lib/rubocop/file_inspector.rb:21:in `each'
/home/user/rubocop/lib/rubocop/file_inspector.rb:21:in `process_files'
/home/user/rubocop/lib/rubocop/cli.rb:31:in `run'
bin/rubocop:14:in `block in <main>'
/home/user/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
bin/rubocop:13:in `<main>'
.

1 file inspected, no offences detected

1 error occurred:
An error occurred while UselessAssignment cop was inspecting /home/user/some-project/test.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.16.0 (using Parser 2.1.1, running on ruby 2.0.0 x86_64-linux)
Finished in 0.011428515 seconds
@bbatsov
Copy link
Collaborator

bbatsov commented Jan 1, 2014

@yujinakayama would you have a look at this?

@yujinakayama
Copy link
Collaborator

OK.

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

3 participants