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

Minitest/AssertRaisesCompoundBody cannot handle an empty block #287

Closed
G-Rath opened this issue Dec 29, 2023 · 0 comments · Fixed by #288
Closed

Minitest/AssertRaisesCompoundBody cannot handle an empty block #287

G-Rath opened this issue Dec 29, 2023 · 0 comments · Fixed by #288

Comments

@G-Rath
Copy link
Contributor

G-Rath commented Dec 29, 2023

Initially this was because the CI for react-rails started to fail using the latest version of rubocop-minitest (CI run: https://github.com/reactjs/react-rails/actions/runs/7359116855/job/20033404076?pr=1306), which looks to be because of #285 possibly introducing a bug so that asserts in some cases are now being miscounted.

I was digging into this further when I then found if I use assert_raises with an empty block an error is raised by Minitest/AssertRaisesCompoundBody, which is definitely a bug - it doesn't look like this was introduced by #285 though.

I'd also appreciate if someone could weight in on the possible miscount from Minitest/MultipleAssertions - namely, are calls within assert_raises blocks just considered assertions, or is it actually a bug? I confirmed this is a bug and have opened #289

Expected behavior

Rubocop should pass, since the code is valid

Actual behavior

Rubocop raises an error.

Steps to reproduce the problem

class MyTests < ActiveSupport::TestCase
  test "#render errors include stack traces" do
    err = assert_raises React::ServerRendering::PrerenderError do
      # @renderer.render("NonExistentComponent", {}, nil)
    end

    assert_match(/NonExistentComponent/, err.to_s, "it names the component")

    assert_match(/\n/, err.to_s, "it includes the multi-line backtrace")
  end
end

RuboCop version

$ [bundle exec] rubocop -V
1.59.0 (using Parser 3.2.2.4, rubocop-ast 1.30.0, running on ruby 3.2.2) [x86_64-linux]
  - rubocop-minitest 0.34.2
Full output with stack trace
For /home/jones/workspace/projects-scrap/rubocop-minitest-bug: configuration from /home/jones/workspace/projects-scrap/rubocop-minitest-bug/.rubocop.yml
configuration from /home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.2/config/default.yml
configuration from /home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.2/config/default.yml
Default configuration from /home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/config/default.yml
Use parallel by default.
Running parallel inspection
Loading cache from /home/jones/.cache/rubocop_cache/db832e8713e45fee0102ff91441af06e8109b720/6d7a3b621ca1730e04accd938619e4bdab66cfb1/d2e653419e56c908210debf3043ada3d3f1d6fc2
An error occurred while Minitest/AssertRaisesCompoundBody cop was inspecting /home/jones/workspace/projects-scrap/rubocop-minitest-bug/test/mine_test.rb:5:10.
undefined method `begin_type?' for nil:NilClass
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.2/lib/rubocop/cop/minitest/assert_raises_compound_body.rb:40:in `multi_statement_begin?'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.2/lib/rubocop/cop/minitest/assert_raises_compound_body.rb:32:in `on_block'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:107:in `public_send'
/home/jones/.rbenv/versions/3.2.2/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'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:105:in `each'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:69:in `on_block'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:135:in `on_lvasgn'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_lvasgn'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `each'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `on_dstr'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:158:in `on_block'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_block'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:154:in `on_class'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:87:in `investigate'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/team.rb:156:in `investigate_partial'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/team.rb:98:in `investigate'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:345:in `block in inspect_file'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `each'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `flat_map'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `inspect_file'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:287:in `block in do_inspection_loop'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:321:in `block in iterate_until_no_changes'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:314:in `loop'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:314:in `iterate_until_no_changes'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:283:in `do_inspection_loop'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:164:in `block in file_offenses'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:189:in `file_offense_cache'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:163:in `file_offenses'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:99:in `block in warm_cache'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.24.0/lib/parallel.rb:627:in `call_with_index'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.24.0/lib/parallel.rb:597:in `process_incoming_jobs'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.24.0/lib/parallel.rb:577:in `block in worker'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.24.0/lib/parallel.rb:568:in `fork'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.24.0/lib/parallel.rb:568:in `worker'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.24.0/lib/parallel.rb:559:in `block in create_workers'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.24.0/lib/parallel.rb:558:in `each'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.24.0/lib/parallel.rb:558:in `each_with_index'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.24.0/lib/parallel.rb:558:in `create_workers'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.24.0/lib/parallel.rb:497:in `work_in_processes'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.24.0/lib/parallel.rb:291:in `map'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/parallel-1.24.0/lib/parallel.rb:235:in `each'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:99:in `warm_cache'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:72:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command.rb:11:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/environment.rb:18:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:118:in `run_command'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:125:in `execute_runners'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:51:in `block in run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:77:in `profile_if_needed'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:43:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/exe/rubocop:19:in `block in <top (required)>'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/exe/rubocop:19:in `<top (required)>'
/home/jones/.rbenv/versions/3.2.2/bin/rubocop:25:in `load'
/home/jones/.rbenv/versions/3.2.2/bin/rubocop:25:in `<top (required)>'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `load'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `kernel_load'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:23:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli.rb:492:in `exec'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli.rb:34:in `dispatch'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli.rb:28:in `start'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/libexec/bundle:45:in `block in <top (required)>'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/libexec/bundle:33:in `<top (required)>'
/home/jones/.rbenv/versions/3.2.2/bin/bundle:25:in `load'
/home/jones/.rbenv/versions/3.2.2/bin/bundle:25:in `<main>'
An error occurred while Minitest/AssertRaisesCompoundBody cop was inspecting /home/jones/workspace/projects-scrap/rubocop-minitest-bug/test/mine_test.rb:5:10.
Inspecting 2 files
Scanning /home/jones/workspace/projects-scrap/rubocop-minitest-bug/Gemfile
Loading cache from /home/jones/.cache/rubocop_cache/db832e8713e45fee0102ff91441af06e8109b720/6d7a3b621ca1730e04accd938619e4bdab66cfb1/d2e653419e56c908210debf3043ada3d3f1d6fc2
.Scanning /home/jones/workspace/projects-scrap/rubocop-minitest-bug/test/mine_test.rb
undefined method `begin_type?' for nil:NilClass
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.2/lib/rubocop/cop/minitest/assert_raises_compound_body.rb:40:in `multi_statement_begin?'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-minitest-0.34.2/lib/rubocop/cop/minitest/assert_raises_compound_body.rb:32:in `on_block'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:107:in `public_send'
/home/jones/.rbenv/versions/3.2.2/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'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:105:in `each'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:69:in `on_block'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:135:in `on_lvasgn'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_lvasgn'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `each'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:137:in `on_dstr'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:158:in `on_block'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_block'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:154:in `on_class'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-ast-1.30.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/commissioner.rb:87:in `investigate'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/team.rb:156:in `investigate_partial'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cop/team.rb:98:in `investigate'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:345:in `block in inspect_file'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `each'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `flat_map'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:344:in `inspect_file'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:287:in `block in do_inspection_loop'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:321:in `block in iterate_until_no_changes'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:314:in `loop'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:314:in `iterate_until_no_changes'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:283:in `do_inspection_loop'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:164:in `block in file_offenses'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:189:in `file_offense_cache'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:163:in `file_offenses'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:154:in `process_file'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `each'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `reduce'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:134:in `each_inspected_file'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:120:in `inspect_files'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/runner.rb:73:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/command.rb:11:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli/environment.rb:18:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:118:in `run_command'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:125:in `execute_runners'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:51:in `block in run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:77:in `profile_if_needed'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/lib/rubocop/cli.rb:43:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/exe/rubocop:19:in `block in <top (required)>'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/rubocop-1.59.0/exe/rubocop:19:in `<top (required)>'
/home/jones/.rbenv/versions/3.2.2/bin/rubocop:25:in `load'
/home/jones/.rbenv/versions/3.2.2/bin/rubocop:25:in `<top (required)>'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `load'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:58:in `kernel_load'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli/exec.rb:23:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli.rb:492:in `exec'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli.rb:34:in `dispatch'
1 error occurred:
An error occurred while Minitest/AssertRaisesCompoundBody cop was inspecting /home/jones/workspace/projects-scrap/rubocop-minitest-bug/test/mine_test.rb:5:10.
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) [x86_64-linux]

/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/cli.rb:28:in `start'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/libexec/bundle:45:in `block in <top (required)>'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/3.2.0/bundler/friendly_errors.rb:117:in `with_friendly_errors'
/home/jones/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/bundler-2.4.10/libexec/bundle:33:in `<top (required)>'
/home/jones/.rbenv/versions/3.2.2/bin/bundle:25:in `load'
/home/jones/.rbenv/versions/3.2.2/bin/bundle:25:in `<main>'
.

2 files inspected, no offenses detected
Finished in 0.26197061099810526 seconds
@G-Rath G-Rath changed the title Rules with assert_raises cannot handle an empty block Minitest/AssertRaisesCompoundBody cannot handle an empty block Dec 29, 2023
@koic koic closed this as completed in #288 Dec 30, 2023
koic added a commit that referenced this issue Dec 30, 2023
[Fix #287] don't error on empty blocks when linting `assert_raises`
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.

1 participant