-
-
Notifications
You must be signed in to change notification settings - Fork 285
Closed
Closed
Copy link
Labels
bugSomething isn't workingSomething isn't working
Description
Rubocop Ralis gem raises errors on my codebase after upgrading to version 2.33.0. It seems the Rails/TransactionExitStatement cop is the culprit. In particular, with variables named transaction.
Expand for error details
❯ rubocop -d test.rb
For /Users/orien/src: configuration from /Users/orien/src/.rubocop.yml
Default configuration from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/config/default.yml
Plugin configuration from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-capybara-2.22.1/config/default.yml
Plugin configuration from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-performance-1.25.0/config/default.yml
Plugin configuration from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-rails-2.33.0/config/default.yml
Plugin configuration from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-rspec-3.6.0/config/default.yml
Inheriting configuration from /Users/orien/src/.rubocop_todo.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning /Users/orien/src/test.rb
An error occurred while Rails/TransactionExitStatement cop was inspecting /Users/orien/src/test.rb:8:13.
/Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-rails-2.33.0/lib/rubocop/cop/rails/transaction_exit_statement.rb:100:in `in_transaction_block?': undefined method `body' for an instance of RuboCop::AST::SendNode (NoMethodError)
return false unless node.parent&.body
^^^^^^
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-rails-2.33.0/lib/rubocop/cop/rails/transaction_exit_statement.rb:84:in `on_send'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:107:in `public_send'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:105:in `each'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:69:in `on_send'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:169:in `block in on_send'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:166:in `each'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:166:in `each_with_index'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:166:in `on_send'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:71:in `on_send'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:169:in `block in on_send'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:166:in `each'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:166:in `each_with_index'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:166:in `on_send'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:71:in `on_send'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:169:in `block in on_send'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:166:in `each'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:166:in `each_with_index'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:166:in `on_send'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:71:in `on_send'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:167:in `on_block'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:71:in `on_block'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:167:in `on_block'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:71:in `on_block'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in `block in on_dstr'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in `each'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:146:in `on_dstr'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:167:in `on_block'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:71:in `on_block'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.46.0/lib/rubocop/ast/traversal.rb:20:in `walk'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/commissioner.rb:87:in `investigate'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/team.rb:174:in `investigate_partial'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cop/team.rb:108:in `investigate'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:348:in `block in inspect_file'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:347:in `each'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:347:in `flat_map'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:347:in `inspect_file'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:290:in `block in do_inspection_loop'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:324:in `block in iterate_until_no_changes'
from <internal:kernel>:187:in `loop'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:317:in `iterate_until_no_changes'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:286:in `do_inspection_loop'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:167:in `block in file_offenses'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:192:in `file_offense_cache'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:166:in `file_offenses'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:154:in `process_file'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:134:in `each'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:134:in `reduce'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:134:in `each_inspected_file'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:120:in `inspect_files'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/runner.rb:73:in `run'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cli/command.rb:11:in `run'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cli/environment.rb:18:in `run'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cli.rb:123:in `run_command'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cli.rb:130:in `execute_runners'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cli.rb:52:in `block in run'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cli.rb:82:in `profile_if_needed'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/lib/rubocop/cli.rb:43:in `run'
from /Users/orien/.asdf/installs/ruby/3.3.9/lib/ruby/gems/3.3.0/gems/rubocop-1.79.2/exe/rubocop:19:in `<top (required)>'
from ./bin/rubocop:29:in `load'
from ./bin/rubocop:29:in `<main>'
.
1 file inspected, no offenses detected
1 error occurred:
An error occurred while Rails/TransactionExitStatement cop was inspecting /Users/orien/src/test.rb:8:13.
configuration from /Users/orien/src/.rubocop.yml
Errors are usually caused by RuboCop bugs.
Please, update to the latest RuboCop version if not already in use, and report a bug if the issue still occurs on this version.
https://github.com/rubocop/rubocop/issues
Mention the following information in the issue report:
1.79.2 (using Parser 3.3.9.0, Prism 1.4.0, rubocop-ast 1.46.0, analyzing as Ruby 3.3, running on ruby 3.3.9) [arm64-darwin24]
Finished in 0.3030949999811128 seconds
Steps to reproduce the problem
Create a test.rb file with this content.
RSpec.describe MyTransaction do
subject(:transaction) { MyTransaction.new }
describe '#timestamp' do
it 'is 180 days ago' do
expect(transaction.timestamp).to eq(180.days.ago)
end
end
endRun Rubocop with the rubocop-rails gem activated.
rubocop ./test.rbRuboCop version
❯ rubocop -V
1.79.2 (using Parser 3.3.9.0, Prism 1.4.0, rubocop-ast 1.46.0, analyzing as Ruby 3.3, running on ruby 3.3.9) [arm64-darwin24]
- rubocop-capybara 2.22.1
- rubocop-performance 1.25.0
- rubocop-rails 2.33.0
- rubocop-rspec 3.6.0
duke-cmcg and cmc-patrickduke-cmcg
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working