lib/rubocop/cop/rails/transaction_exit_statement.rb in rubocop-rails-2.26.2 vs lib/rubocop/cop/rails/transaction_exit_statement.rb in rubocop-rails-2.27.0

- old
+ new

@@ -13,10 +13,14 @@ # error when rollback is desired, and to use `next` when commit is # desired. # # If you are defining custom transaction methods, you can configure it with `TransactionMethods`. # + # NOTE: This cop is disabled on Rails >= 7.2 because transactions were restored + # to their historical behavior. In Rails 7.1, the behavior is controlled with + # the config `active_record.commit_transaction_on_non_local_return`. + # # @example # # bad # ApplicationRecord.transaction do # return if user.active? # end @@ -74,9 +78,10 @@ ... ) PATTERN def on_send(node) + return if target_rails_version >= 7.2 return unless in_transaction_block?(node) exit_statements(node.parent.body).each do |statement_node| next if statement_node.break_type? && nested_block?(statement_node)