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 occurred while VariableForce cop on v1.54.0 #12014

Closed
arika opened this issue Jul 3, 2023 · 0 comments · Fixed by #12018
Closed

An error occurred while VariableForce cop on v1.54.0 #12014

arika opened this issue Jul 3, 2023 · 0 comments · Fixed by #12018
Labels

Comments

@arika
Copy link
Contributor

arika commented Jul 3, 2023

test.rb:

# frozen_string_literal: true

a, (b, c) = z # <- This line cause an error.
p a, b

Expected behavior

No errors occurred.

Actual behavior

$ bundle exec rubocop -d test.rb
For /.../work: configuration from /.../work/.rubocop.yml
configuration from /.../lib/ruby/gems/3.1.0/gems/rubocop-factory_bot-2.23.1/config/default.yml
Default configuration from /.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/config/default.yml
configuration from /.../lib/ruby/gems/3.1.0/gems/rubocop-factory_bot-2.23.1/lib/../config/default.yml
configuration from /.../lib/ruby/gems/3.1.0/gems/rubocop-minitest-0.31.0/config/default.yml
configuration from /.../lib/ruby/gems/3.1.0/gems/rubocop-minitest-0.31.0/config/default.yml
configuration from /.../lib/ruby/gems/3.1.0/gems/rubocop-performance-1.18.0/config/default.yml
configuration from /.../lib/ruby/gems/3.1.0/gems/rubocop-performance-1.18.0/config/default.yml
configuration from /.../lib/ruby/gems/3.1.0/gems/rubocop-rails-2.20.2/config/default.yml
configuration from /.../lib/ruby/gems/3.1.0/gems/rubocop-rails-2.20.2/config/default.yml
configuration from /.../lib/ruby/gems/3.1.0/gems/rubocop-rake-0.6.0/config/default.yml
configuration from /.../lib/ruby/gems/3.1.0/gems/rubocop-rake-0.6.0/config/default.yml
Inspecting 1 file
Scanning /.../work/test.rb
An error occurred while VariableForce cop was inspecting /.../work/test.rb.
undefined method `source' for nil:NilClass

          corrector.replace(node, node.expression.source)
                                                 ^^^^^^^
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/lint/useless_assignment.rb:178:in `remove_local_variable_assignment_part'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/lint/useless_assignment.rb:148:in `autocorrect'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/lint/useless_assignment.rb:69:in `block (2 levels) in check_for_unused_assignments'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/base.rb:377:in `correct'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/base.rb:181:in `add_offense'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/lint/useless_assignment.rb:68:in `block in check_for_unused_assignments'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/lint/useless_assignment.rb:57:in `each'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/lint/useless_assignment.rb:57:in `check_for_unused_assignments'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/lint/useless_assignment.rb:51:in `block in after_leaving_scope'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/lint/useless_assignment.rb:51:in `each_value'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/lint/useless_assignment.rb:51:in `after_leaving_scope'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/force.rb:34:in `public_send'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/force.rb:34:in `block in run_hook'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/force.rb:31:in `each'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/force.rb:31:in `run_hook'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/variable_force.rb:370:in `block (2 levels) in <class:VariableForce>'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/variable_force/variable_table.rb:17:in `invoke_hook'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/variable_force/variable_table.rb:36:in `pop_scope'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/variable_force.rb:82:in `investigate'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/commissioner.rb:164:in `block (2 levels) in invoke_with_argument'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/commissioner.rb:164:in `block in invoke_with_argument'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/commissioner.rb:164:in `each'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/commissioner.rb:164:in `invoke_with_argument'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/commissioner.rb:85:in `investigate'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/team.rb:156:in `investigate_partial'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cop/team.rb:98:in `investigate'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:345:in `block in inspect_file'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:344:in `each'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:344:in `flat_map'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:344:in `inspect_file'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:287:in `block in do_inspection_loop'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:321:in `block in iterate_until_no_changes'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:314:in `loop'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:314:in `iterate_until_no_changes'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:283:in `do_inspection_loop'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:164:in `block in file_offenses'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:189:in `file_offense_cache'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:163:in `file_offenses'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:154:in `process_file'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:134:in `each'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:134:in `reduce'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:134:in `each_inspected_file'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:120:in `inspect_files'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/runner.rb:73:in `run'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cli/command.rb:11:in `run'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cli/environment.rb:18:in `run'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cli.rb:118:in `run_command'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cli.rb:125:in `execute_runners'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cli.rb:51:in `block in run'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cli.rb:77:in `profile_if_needed'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/lib/rubocop/cli.rb:43:in `run'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/exe/rubocop:19:in `block in <top (required)>'
/.../lib/ruby/3.1.0/benchmark.rb:311:in `realtime'
/.../lib/ruby/gems/3.1.0/gems/rubocop-1.54.0/exe/rubocop:19:in `<top (required)>'
/.../bin/rubocop:25:in `load'
/.../bin/rubocop:25:in `<top (required)>'
/.../lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `load'
/.../lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `kernel_load'
/.../lib/ruby/3.1.0/bundler/cli/exec.rb:23:in `run'
/.../lib/ruby/3.1.0/bundler/cli.rb:486:in `exec'
/.../lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/.../lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/.../lib/ruby/3.1.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/.../lib/ruby/3.1.0/bundler/cli.rb:31:in `dispatch'
/.../lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/.../lib/ruby/3.1.0/bundler/cli.rb:25:in `start'
/.../lib/ruby/gems/3.1.0/gems/bundler-2.3.26/libexec/bundle:48:in `block in <top (required)>'
/.../lib/ruby/3.1.0/bundler/friendly_errors.rb:120:in `with_friendly_errors'
/.../lib/ruby/gems/3.1.0/gems/bundler-2.3.26/libexec/bundle:36:in `<top (required)>'
/.../bin/bundle:25:in `load'
/.../bin/bundle:25:in `<main>'
.

1 file inspected, no offenses detected

1 error occurred:
An error occurred while VariableForce cop was inspecting /.../work/test.rb.
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.54.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.1.4) [arm64-darwin22]
Finished in 0.2845159999851603 seconds

Steps to reproduce the problem

bundle exec rubocop test.rb

RuboCop version

$ bundle exec rubocop -V
1.54.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.1.4) [arm64-darwin22]
  - rubocop-factory_bot 2.23.1
  - rubocop-minitest 0.31.0
  - rubocop-performance 1.18.0
  - rubocop-rails 2.20.2
  - rubocop-rake 0.6.0
@koic koic added the bug label Jul 3, 2023
koic added a commit to koic/rubocop that referenced this issue Jul 3, 2023
Fixes rubocop#12014.

This PR fixes an error for `Lint/UselessAssignment`
when part of a multiple assignment is enclosed in parentheses.
bbatsov pushed a commit that referenced this issue Jul 3, 2023
Fixes #12014.

This PR fixes an error for `Lint/UselessAssignment`
when part of a multiple assignment is enclosed in parentheses.
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