You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of rubocop-minitest 0.34.0, Rubocop Minitest produces a large number of errors of the form An error occurred while [cop] cop was inspecting [file] when run against source that uses setter methods. I've seen this with the Minitest/EmptyLineBeforeAssertionMethods and Minitest/MultipleAssertions cops, though it may also happen with others.
When running rubocop with -d, the errors all raise at lib/rubocop/cop/mixin/minitest_exploration_helpers.rb:103:in `assertion_method?'.
I have confirmed the problem doesn't occur with rubocop-minitest 0.33.0, both by uninstalling 0.34.0 and by running rubocop in a bundle that locks rubocop-minitest 0.33.0.
Expected behavior
If RuboCop Minitest 0.33.0 was able to inspect a test file, RuboCop Minitest 0.34.0 should be able to inspect a test file. It might report issues it wasn't able to report before, but it shouldn't fail with apparently spurious errors.
Actual behavior
RuboCop Minitest 0.34.0 fails at class boundaries or individual lines, failing out in RuboCop::Cop::MinitestExplorationHelpers#assertion_method?
Steps to reproduce the problem
Set up project such that it uses rubocop-minitest (which is to say: in the Gemfile and in .rubocop.yml).
Create a test file that uses a setter method.
Run rubocop on that test file.
Below, I've included a test case that always fails for me, as well as the output of such a run.
require "test_helper"
class Stub
attr_accessor :foo
end
class ExampleTest < ActiveSupport::TestCase
test "the truth" do
var = Stub.new
var.foo = 1
assert var.foo
end
end
Running rubocop test/models/example_test.rb -d I get:
For /Users/faisal/rs: configuration from /Users/faisal/rs/.rubocop.yml
configuration from /opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-rails-2.23.0/config/default.yml
configuration from /opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-rails-2.23.0/config/default.yml
Default configuration from /opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/config/default.yml
configuration from /opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/config/default.yml
configuration from /opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/config/default.yml
configuration from /opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-performance-1.20.0/config/default.yml
configuration from /opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-performance-1.20.0/config/default.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning /Users/faisal/rs/test/models/example_test.rb
An error occurred while Minitest/MultipleAssertions cop was inspecting /Users/faisal/rs/test/models/example_test.rb:7:0.
undefined method `expression' for s(:send,
s(:lvar, :var), :foo=,
s(:int, 1)):RuboCop::AST::SendNode
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb:103:in `assertion_method?'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/minitest/multiple_assertions.rb:68:in `assertions_count'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/minitest/multiple_assertions.rb:65:in `block in assertions_count'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:28:in `block in each_child_node'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/node/mixin/descendence.rb:25:in `each_child_node'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/minitest/multiple_assertions.rb:65:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/minitest/multiple_assertions.rb:65:in `sum'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/minitest/multiple_assertions.rb:65:in `assertions_count'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/minitest/multiple_assertions.rb:40:in `block in on_class'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/minitest/multiple_assertions.rb:39:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/minitest/multiple_assertions.rb:39:in `on_class'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:107:in `public_send'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:105:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:69:in `on_class'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `on_dstr'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:87:in `investigate'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/team.rb:156:in `investigate_partial'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/team.rb:98:in `investigate'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:345:in `block in inspect_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `flat_map'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `inspect_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:287:in `block in do_inspection_loop'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:321:in `block in iterate_until_no_changes'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:314:in `loop'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:314:in `iterate_until_no_changes'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:283:in `do_inspection_loop'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:164:in `block in file_offenses'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:189:in `file_offense_cache'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:163:in `file_offenses'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:154:in `process_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `reduce'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `each_inspected_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:120:in `inspect_files'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:73:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command.rb:11:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/environment.rb:18:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:118:in `run_command'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:125:in `execute_runners'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:51:in `block in run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:77:in `profile_if_needed'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:43:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/exe/rubocop:19:in `block in <top (required)>'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/benchmark-0.3.0/lib/benchmark.rb:313:in `realtime'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/exe/rubocop:19:in `<top (required)>'
/opt/homebrew/lib/ruby/gems/3.2.0/bin/rubocop:25:in `load'
/opt/homebrew/lib/ruby/gems/3.2.0/bin/rubocop:25:in `<main>'
An error occurred while Minitest/EmptyLineBeforeAssertionMethods cop was inspecting /Users/faisal/rs/test/models/example_test.rb:10:4.
undefined method `expression' for s(:send,
s(:lvar, :var), :foo=,
s(:int, 1)):RuboCop::AST::SendNode
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb:103:in `assertion_method?'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/minitest/empty_line_before_assertion_methods.rb:44:in `assertion_method'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/minitest/empty_line_before_assertion_methods.rb:28:in `on_send'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:107:in `public_send'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:105:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:69:in `on_send'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `on_dstr'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:158:in `on_block'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_block'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:154:in `on_class'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `on_dstr'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:87:in `investigate'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/team.rb:156:in `investigate_partial'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/team.rb:98:in `investigate'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:345:in `block in inspect_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `flat_map'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `inspect_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:287:in `block in do_inspection_loop'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:321:in `block in iterate_until_no_changes'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:314:in `loop'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:314:in `iterate_until_no_changes'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:283:in `do_inspection_loop'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:164:in `block in file_offenses'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:189:in `file_offense_cache'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:163:in `file_offenses'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:154:in `process_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `reduce'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `each_inspected_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:120:in `inspect_files'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:73:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command.rb:11:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/environment.rb:18:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:118:in `run_command'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:125:in `execute_runners'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:51:in `block in run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:77:in `profile_if_needed'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:43:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/exe/rubocop:19:in `block in <top (required)>'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/benchmark-0.3.0/lib/benchmark.rb:313:in `realtime'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/exe/rubocop:19:in `<top (required)>'
/opt/homebrew/lib/ruby/gems/3.2.0/bin/rubocop:25:in `load'
/opt/homebrew/lib/ruby/gems/3.2.0/bin/rubocop:25:in `<main>'
An error occurred while Minitest/EmptyLineBeforeAssertionMethods cop was inspecting /Users/faisal/rs/test/models/example_test.rb:12:4.
undefined method `expression' for s(:send,
s(:lvar, :var), :foo=,
s(:int, 1)):RuboCop::AST::SendNode
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/mixin/minitest_exploration_helpers.rb:103:in `assertion_method?'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/minitest/empty_line_before_assertion_methods.rb:56:in `accept_previous_line?'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.0/lib/rubocop/cop/minitest/empty_line_before_assertion_methods.rb:31:in `on_send'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:107:in `public_send'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:105:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:69:in `on_send'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `on_dstr'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:158:in `on_block'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_block'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:154:in `on_class'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `on_dstr'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:87:in `investigate'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/team.rb:156:in `investigate_partial'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/team.rb:98:in `investigate'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:345:in `block in inspect_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `flat_map'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `inspect_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:287:in `block in do_inspection_loop'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:321:in `block in iterate_until_no_changes'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:314:in `loop'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:314:in `iterate_until_no_changes'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:283:in `do_inspection_loop'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:164:in `block in file_offenses'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:189:in `file_offense_cache'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:163:in `file_offenses'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:154:in `process_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `each'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `reduce'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `each_inspected_file'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:120:in `inspect_files'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:73:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command.rb:11:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/environment.rb:18:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:118:in `run_command'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:125:in `execute_runners'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:51:in `block in run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:77:in `profile_if_needed'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:43:in `run'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/exe/rubocop:19:in `block in <top (required)>'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/benchmark-0.3.0/lib/benchmark.rb:313:in `realtime'
/opt/homebrew/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/exe/rubocop:19:in `<top (required)>'
/opt/homebrew/lib/ruby/gems/3.2.0/bin/rubocop:25:in `load'
/opt/homebrew/lib/ruby/gems/3.2.0/bin/rubocop:25:in `<main>'
.
1 file inspected, no offenses detected
3 errors occurred:
An error occurred while Minitest/MultipleAssertions cop was inspecting /Users/faisal/rs/test/models/example_test.rb:7:0.
An error occurred while Minitest/EmptyLineBeforeAssertionMethods cop was inspecting /Users/faisal/rs/test/models/example_test.rb:10:4.
An error occurred while Minitest/EmptyLineBeforeAssertionMethods cop was inspecting /Users/faisal/rs/test/models/example_test.rb:12:4.
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.59.0 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.2.2) [arm64-darwin23]
Finished in 0.32425900001544505 seconds
The text was updated successfully, but these errors were encountered:
As of rubocop-minitest 0.34.0, Rubocop Minitest produces a large number of errors of the form
An error occurred while [cop] cop was inspecting [file]
when run against source that uses setter methods. I've seen this with the Minitest/EmptyLineBeforeAssertionMethods and Minitest/MultipleAssertions cops, though it may also happen with others.When running rubocop with
-d
, the errors all raise at lib/rubocop/cop/mixin/minitest_exploration_helpers.rb:103:in `assertion_method?'.I have confirmed the problem doesn't occur with rubocop-minitest 0.33.0, both by uninstalling 0.34.0 and by running rubocop in a bundle that locks rubocop-minitest 0.33.0.
Expected behavior
If RuboCop Minitest 0.33.0 was able to inspect a test file, RuboCop Minitest 0.34.0 should be able to inspect a test file. It might report issues it wasn't able to report before, but it shouldn't fail with apparently spurious errors.
Actual behavior
RuboCop Minitest 0.34.0 fails at class boundaries or individual lines, failing out in RuboCop::Cop::MinitestExplorationHelpers#assertion_method?
Steps to reproduce the problem
Below, I've included a test case that always fails for me, as well as the output of such a run.
RuboCop version
Test case
test/models/example_test.rb:
Running rubocop test/models/example_test.rb -d I get:
The text was updated successfully, but these errors were encountered: