-
-
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/SaveBang does not account for control flow #53
Labels
bug
Something isn't working
Comments
👋 :) |
koic
added a commit
to koic/rubocop-rails
that referenced
this issue
Jul 20, 2019
Fixes rubocop#53. This PR fixes a false positive for `Rails/SaveBang` when implicitly return using finder method and creation method connected by `||`. And this PR updates .rubocop_todo.yml with `rubocop --auto_gen_config` to prevent the following offense. ```console % rubocop lib/rubocop/cop/rails/save_bang.rb Inspecting 1 file C Offenses: lib/rubocop/cop/rails/save_bang.rb:100:7: C: Metrics/ClassLength: Class has too many lines. [164/159] class SaveBang < Cop ... ^^^^^^^^^^^^^^^^^^^^ 1 file inspected, 1 offense detected ```
koic
added a commit
to koic/rubocop-rails
that referenced
this issue
Jul 20, 2019
Fixes rubocop#53. This PR fixes a false positive for `Rails/SaveBang` when implicitly return using finder method and creation method connected by `||`. And this PR updates .rubocop_todo.yml with `rubocop --auto_gen_config` to prevent the following offense. ```console % rubocop lib/rubocop/cop/rails/save_bang.rb Inspecting 1 file C Offenses: lib/rubocop/cop/rails/save_bang.rb:100:7: C: Metrics/ClassLength: Class has too many lines. [164/159] class SaveBang < Cop ... ^^^^^^^^^^^^^^^^^^^^ 1 file inspected, 1 offense detected ```
8 tasks
koic
added a commit
that referenced
this issue
Jul 22, 2019
…bang [Fix #53] Fix a false positive for `Rails/SaveBang`
Thank you very much! :-D |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
I expect the following code to be allowed by rubocop, because the value of the
create
method is (possibly) returned by the function, andAllowImplicitReturn
is true by default.Actual behavior
The Rails/SaveBang cop reports that I should use
create!
instead ofcreate
.Steps to reproduce the problem
Assuming you have Rails cops enabled. Save the following file and run
rubocop filename.rb
.RuboCop version
The text was updated successfully, but these errors were encountered: