-
-
Notifications
You must be signed in to change notification settings - Fork 265
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/SaveBang "check used in conditional" false positive #120
Labels
bug
Something isn't working
Comments
jas14
added a commit
to jas14/rubocop-rails
that referenced
this issue
Aug 28, 2019
Fixes rubocop#120. The Rails/SaveBang rule emitted incorrect errors about using the return value of save-like calls in conditional nodes. It did not differentiate between such calls in the body versus the condition, where only the latter is necessarily a boolean expression.
jas14
added a commit
to jas14/rubocop-rails
that referenced
this issue
Aug 28, 2019
Fixes rubocop#120. The Rails/SaveBang rule emitted incorrect errors about using the return value of save-like calls in conditional nodes. It did not differentiate between such calls in the body versus the condition, where only the latter is necessarily a boolean expression.
jas14
added a commit
to jas14/rubocop-rails
that referenced
this issue
Aug 28, 2019
Fixes rubocop#120. The Rails/SaveBang rule emitted incorrect errors about using the return value of save-like calls in conditional nodes. It did not differentiate between such calls in the body versus the condition, where only the latter is necessarily a boolean expression.
8 tasks
FYI this applies to save-like calls in any branch body of a conditional. Examples:
|
jas14
added a commit
to jas14/rubocop-rails
that referenced
this issue
Sep 11, 2019
Fixes rubocop#120. The Rails/SaveBang rule emitted incorrect errors about using the return value of save-like calls in conditional nodes. It did not differentiate between such calls in the body versus the condition, where only the latter is necessarily a boolean expression.
jas14
added a commit
to jas14/rubocop-rails
that referenced
this issue
Sep 13, 2019
Fixes rubocop#120. The Rails/SaveBang rule emitted incorrect errors about using the return value of save-like calls in conditional nodes. It did not differentiate between such calls in the body versus the condition, where only the latter is necessarily a boolean expression.
jas14
added a commit
to jas14/rubocop-rails
that referenced
this issue
Sep 16, 2019
Fixes rubocop#120. The Rails/SaveBang rule emitted incorrect errors about using the return value of save-like calls in conditional nodes. It did not differentiate between such calls in the body versus the condition, where only the latter is necessarily a boolean expression.
koic
added a commit
that referenced
this issue
Sep 17, 2019
[Fix #120] Fix save-in-conditional checking in `Rails/SaveBang`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The Rails/SaveBang cop in v0.74.0 emits a false positive for the "check used in conditional" rule, where the save-like call is actually in the if-body, not the condition.
Expected behavior
I expect Rails/SaveBang to suggest I use
create!
instead ofcreate
, like so:Actual behavior
I get a message about the save-like call being used as a conditional:
Steps to reproduce the problem
test.rb
) with the following minimum reproducible case code:rubocop test.rb
RuboCop version
The text was updated successfully, but these errors were encountered: