-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Add Configurable option for Rails/TransactionExitStatement
#1072
Add Configurable option for Rails/TransactionExitStatement
#1072
Conversation
dcb05f6
to
ad71894
Compare
I understand the use case. However built-in transaction methods and custom methods should not be treated the same I think. So, can you update this PR to mixin the |
b28c1ff
to
5bf66ea
Compare
Thanks for review. |
@@ -0,0 +1 @@ | |||
* [#1072](https://github.com/rubocop/rubocop-rails/pull/1072): Add `AllowedMethods` and `AllowedPatterns` for `Rails/TransactionExitStatement`. ([@marocchino][]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's just my two cents. Can you rename this file to changelog/new_add_allow_methods_and_allow_patterns_to_transaction_exit_statement.md?
config/default.yml
Outdated
AllowedMethods: [] | ||
AllowedPatterns: [] | ||
Enabled: pending | ||
VersionAdded: '2.14' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you tweak it?
AllowedMethods: [] | |
AllowedPatterns: [] | |
Enabled: pending | |
VersionAdded: '2.14' | |
Enabled: pending | |
VersionAdded: '2.14' | |
AllowedMethods: [] | |
AllowedPatterns: [] |
@@ -51,11 +51,14 @@ module Rails | |||
# next if user.active? | |||
# end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add examples for the new option?
5bf66ea
to
9616883
Compare
I applied reviews. |
# | ||
# @example AllowedMethods: ["custom_transaction"] | ||
# # bad | ||
# ApplicationRecord.custom_transaction do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be CustomModel
instead of extending ApplicationRecord
, right?
# ApplicationRecord.custom_transaction do | |
# CustomModel.custom_transaction do |
# | ||
# @example AllowedPatterns: ["_transaction$"] | ||
# # bad | ||
# ApplicationRecord.other_transaction do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
9616883
to
2d3bc1b
Compare
…nExitStatement` Follow up rubocop#1072. This PR renames `AllowedMethods` to `TransactionMethods` for `Rails/TransactionExitStatement` because it's a configuration for detecting, not for allowing custom transaction methods.
@marocchino I made a mistake and merged this. This is a configuration to detect, not to allow custom transaction methods. So I've opened #1088. |
Hi.
We differentiate transactions by using methods with different names depending on the target DB.
So I would like to be able to leave the transaction on_lock as the default and add another method name to use it.
like..
Before submitting the PR make sure the following are checked:
[ ] Commit message starts with[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).bundle exec rake default
. It executes all tests and runs RuboCop on its own code.{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.[ ] If this is a new cop, consider making a corresponding update to the Rails Style Guide.