Skip to content
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

SaveBang checking only works on single condition #3390

Closed
soberstadt opened this issue Aug 9, 2016 · 1 comment
Closed

SaveBang checking only works on single condition #3390

soberstadt opened this issue Aug 9, 2016 · 1 comment
Labels

Comments

@soberstadt
Copy link

When looking for SaveBang violations, if you have a save call as part of an if statement like this it passes:

raise 'saved' if user.save

But if I want to have it part of an chained clause it doesn't work.

raise 'saved' if user.valid? && user.save

Expected behavior

if user.valid? && user.save should pass SaveBang cop

Actual behavior

It suggests I use save! instead

Steps to reproduce the problem

raise 'saved' if user.valid? && user.save

RuboCop version

0.42.0 (using Parser 2.3.1.2, running on ruby 2.3.1 x86_64-darwin15)

@bbatsov bbatsov added the bug label Aug 10, 2016
@bbatsov
Copy link
Collaborator

bbatsov commented Aug 10, 2016

Yep, that's a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants