Open
Description
Is your feature request related to a problem? Please describe.
A common mistake made in our Rails codebase is:
ActiveRecord::Base.transaction do
# create a few records
rescue StandardError => e
# we've rescued too early, meaning no rollback will occur!
end
Instead of
begin
ActiveRecord::Base.transaction do
# create a few records
end
rescue StandardError => e
# the rollback has already occurred by this point, so we're good to go
end
Describe the solution you'd like
A RuboCop rule to prevent this would be brilliant, as the effects to data integrity in production can be devastating
Describe alternatives you've considered
I have tried writing a rule myself, to no avail
Additional context
Add any other context or screenshots about the feature request here.
Metadata
Metadata
Assignees
Labels
No labels