-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
Rails/TransactionExitStatement - not applicable anymore #727
Comments
Any updates on this one? I propose to remove this cop, if no solution can be found. |
It's worth mentioning that, with Rails 7.1, the behavior of See rails/rails#48600 and related info linked from that PR. |
To keep the context flowing: 7.2 deprecates |
Ugh, this one. I always found that behaviour confusing and not something I ever really wanted to think about. I'm glad they did the work to make this more intuitive. Thanks for the reminder, I'll open a PR tomorrow to disable this cop on >= 7.2. You could argue about 7.1 but it depends on the config value 🤷. 7.2 at least is pretty clear |
7.2 still uses the config value, I think, but I'd argue the cop is already "broken" pre-7.2 anyway if it doesn't account for the setting or the change in behavior across versions. You could maybe switch the cop off on > 7.2 rather than >= 7.2? (I likewise avoid |
It doesn't: rails/rails@eccc606
That's a bit more arguable, there's nothing wrong with not using a feature. This is important for engines where the version of rails is not necessarily known upfront. I know that for most users that is not applicable though, most will already have opted in to the new behaviour since the old one shows a deprecation warning. I guess in most cases it is more like a style cop then. PR: #1366 |
Ah. Surprising! I only saw the description of the |
Rails (almost) never removes things without showing a deprecation to potential users. This usually leads to things like this remaining for one extra release cycle, even if their only purpose was to help with deprecated behavior in the first place. |
Of course :) it just seems more confusing to me to have a config called |
[Fix #727] Disable `Rails/TransactionExitStatement` on Rails >= 7.2
As @javierjulio has noticed in this PR, rails/rails/pull/39453 was committed which seems to make this cop condition not applicable. Rails won't emit such deprecation if there is no write to database, whereas
Rails/TransactionExitStatement
doesn't consider that.I'm not sure if there is a way for Rubocop to detect write to database. I don't think so given that Rubocop is just a static analysis tool.
Maybe we should decommission this cop now?
cc: @javierjulio
Expected behavior
This code won't emit deprecation, because there hasn't been any write into database. This is a new behaviour since rails/rails/pull/39453
Actual behavior
Rails/TransactionExitStatement
will flag it.Steps to reproduce the problem
Just run rubocop with this cop on this code.
RuboCop version
Since the version where
Rails/TransactionExitStatement
is introduced.My local version:
The text was updated successfully, but these errors were encountered: