rubocop / rubocop-minitest

Code style checking for Minitest files.
https://docs.rubocop.org/rubocop-minitest
MIT License
144 stars 44 forks source link

Error running Minitest/MultipleAssertions #292

Closed tomhughes closed 11 months ago

tomhughes commented 11 months ago

Expected behavior

I expected it not to crash.

Actual behavior

It crashed:

An error occurred while Minitest/MultipleAssertions cop was inspecting /home/runner/work/openstreetmap-website/openstreetmap-website/test/lib/short_link_test.rb:3:0.
=Scanning /home/runner/work/openstreetmap-website/openstreetmap-website/test/lib/short_link_test.rb
undefined method `expression' for s(:masgn,
  s(:mlhs,
    s(:lvasgn, :lon2),
    s(:lvasgn, :lat2),
    s(:lvasgn, :zoom2)),
  s(:send,
    s(:const, nil, :ShortLink), :decode,
    s(:send,
      s(:const, nil, :ShortLink), :encode,
      s(:lvar, :lon),
      s(:lvar, :lat),
      s(:lvar, :zoom)))):RuboCop::AST::Node
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:78:in `assertions_count_in_assignment'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:70:in `assertions_count_based_on_type'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:56:in `assertions_count'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:72:in `block in assertions_count_based_on_type'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:28:in `block in each_child_node'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each_child_node'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:72:in `each'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:72:in `sum'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:72:in `assertions_count_based_on_type'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:56:in `assertions_count'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:68:in `assertions_count_based_on_type'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:56:in `assertions_count'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:72:in `block in assertions_count_based_on_type'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:28:in `block in each_child_node'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each_child_node'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:72:in `each'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:72:in `sum'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:72:in `assertions_count_based_on_type'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:56:in `assertions_count'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:40:in `block in on_class'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:39:in `each'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-minitest-0.34.3/lib/rubocop/cop/minitest/multiple_assertions.rb:39:in `on_class'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:107:in `public_send'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:105:in `each'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:69:in `on_class'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `each'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `on_dstr'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:87:in `investigate'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cop/team.rb:156:in `investigate_partial'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cop/team.rb:98:in `investigate'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:345:in `block in inspect_file'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `each'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `flat_map'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `inspect_file'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:287:in `block in do_inspection_loop'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:321:in `block in iterate_until_no_changes'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:314:in `loop'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:314:in `iterate_until_no_changes'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:283:in `do_inspection_loop'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:164:in `block in file_offenses'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:189:in `file_offense_cache'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:163:in `file_offenses'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:154:in `process_file'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `each'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `reduce'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `each_inspected_file'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:120:in `inspect_files'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:73:in `run'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cli/command.rb:11:in `run'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cli/environment.rb:18:in `run'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:118:in `run_command'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:125:in `execute_runners'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:51:in `block in run'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:77:in `profile_if_needed'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:43:in `run'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/exe/rubocop:19:in `block in <top (required)>'
/opt/hostedtoolcache/Ruby/3.0.6/x64/lib/ruby/3.0.0/benchmark.rb:308:in `realtime'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/rubocop-1.59.0/exe/rubocop:19:in `<top (required)>'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/bin/rubocop:25:in `load'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/bin/rubocop:25:in `<top (required)>'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `load'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:58:in `kernel_load'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/bundler-2.4.19/lib/bundler/cli/exec.rb:23:in `run'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/bundler-2.4.19/lib/bundler/cli.rb:492:in `exec'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/bundler-2.4.19/lib/bundler/cli.rb:34:in `dispatch'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/bundler-2.4.19/lib/bundler/cli.rb:28:in `start'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/bundler-2.4.19/exe/bundle:37:in `block in <top (required)>'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/bundler-2.4.19/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/home/runner/work/openstreetmap-website/openstreetmap-website/vendor/bundle/ruby/3.0.0/gems/bundler-2.4.19/exe/bundle:29:in `<top (required)>'
/opt/hostedtoolcache/Ruby/3.0.6/x64/bin/bundle:25:in `load'
/opt/hostedtoolcache/Ruby/3.0.6/x64/bin/bundle:25:in `<main>'

RuboCop version

1.59.0 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.2.2) [x86_64-linux]
  - rubocop-capybara 2.19.0
  - rubocop-factory_bot 2.24.0
  - rubocop-minitest 0.34.3
  - rubocop-performance 1.20.1
  - rubocop-rails 2.23.1
  - rubocop-rake 0.6.0
tomhughes commented 11 months ago

I think it's this line that confuses it:

lon2, lat2, zoom2 = ShortLink.decode(ShortLink.encode(lon, lat, zoom))
G-Rath commented 11 months ago

Ah that's the bug I was looking for - it's because of #291, I'll have a PR up shortly