-
-
Notifications
You must be signed in to change notification settings - Fork 285
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Rails/TransactionExitStatement detected on following break but its false positive.
FooModel.transaction do
loop do
break if should_exit? # just exit loop, not transaction
some_works
end
puts "This line is always shown!"
endExpected behavior
No offences detected.
Actual behavior
Rails/TransactionExitStatement detected at break
Steps to reproduce the problem
$ cat test.rb
FooModel.transaction do
loop do
break if should_exit? # just exit loop, not transaction
some_works
end
end
$ bundle exec rubocop test.rb --only Rails
Inspecting 1 file
C
Offenses:
test.rb:3:5: C: Rails/TransactionExitStatement: Exit statement break is not allowed. Use raise (rollback) or next (commit).
break if should_exit? # just exit loop, not transaction
^^^^^
1 file inspected, 1 offense detected
RuboCop version
1.26.0 (using Parser 3.1.1.0, rubocop-ast 1.16.0, running on ruby 2.7.5 x86_64-linux)
- rubocop-rails 2.14.0
bbugh
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working