-
-
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
Not safe refactor when run with rubocop -R -a --safe #111
Labels
bug
Something isn't working
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution and understanding! |
koic
added a commit
to koic/rubocop-rails
that referenced
this issue
Aug 24, 2019
Fixes rubocop#111. This PR fixes incorrect autocorrect for `Rails/Presence` when method arguments of `else` branch is not enclosed in parentheses. The following is a reproduction procedure. ```console % cat example.rb if value.present? value else do_something value end ``` ```console % bundle exec rubocop -a --only Rails/Presence Inspecting 1 file E Offenses: example.rb:1:1: C: [Corrected] Rails/Presence: Use value.presence || do_something value instead of if value.present? value else do_something value end. if value.present? ... ^^^^^^^^^^^^^^^^^ example.rb:1:32: E: Lint/Syntax: unexpected token tIDENTIFIER (Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops) value.presence || do_something value ^^^^^ 1 file inspected, 2 offenses detected, 1 offense corrected ``` ```console % cat example.rb value.presence || do_something value ``` The auto-corrected code is a syntax error. ```console % ruby example.rb example.rb:3: syntax error, unexpected local variable or method, expecting `do' or '{' or '(' ....presence || do_something value ```
8 tasks
koic
added a commit
to koic/rubocop-rails
that referenced
this issue
Aug 24, 2019
Fixes rubocop#111. This PR fixes an incorrect autocorrect for `Rails/Presence` when method arguments of `else` branch is not enclosed in parentheses. The following is a reproduction procedure. ```console % cat example.rb if value.present? value else do_something value end ``` ```console % bundle exec rubocop -a --only Rails/Presence Inspecting 1 file E Offenses: example.rb:1:1: C: [Corrected] Rails/Presence: Use value.presence || do_something value instead of if value.present? value else do_something value end. if value.present? ... ^^^^^^^^^^^^^^^^^ example.rb:1:32: E: Lint/Syntax: unexpected token tIDENTIFIER (Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops) value.presence || do_something value ^^^^^ 1 file inspected, 2 offenses detected, 1 offense corrected ``` ```console % cat example.rb value.presence || do_something value ``` The auto-corrected code is a syntax error. ```console % ruby example.rb example.rb:3: syntax error, unexpected local variable or method, expecting `do' or '{' or '(' ....presence || do_something value ```
koic
added a commit
to koic/rubocop-rails
that referenced
this issue
Aug 26, 2019
Fixes rubocop#111. This PR fixes an incorrect autocorrect for `Rails/Presence` when method arguments of `else` branch is not enclosed in parentheses. The following is a reproduction procedure. ```console % cat example.rb if value.present? value else do_something value end ``` ```console % bundle exec rubocop -a --only Rails/Presence Inspecting 1 file E Offenses: example.rb:1:1: C: [Corrected] Rails/Presence: Use value.presence || do_something value instead of if value.present? value else do_something value end. if value.present? ... ^^^^^^^^^^^^^^^^^ example.rb:1:32: E: Lint/Syntax: unexpected token tIDENTIFIER (Using Ruby 2.7 parser; configure using TargetRubyVersion parameter, under AllCops) value.presence || do_something value ^^^^^ 1 file inspected, 2 offenses detected, 1 offense corrected ``` ```console % cat example.rb value.presence || do_something value ``` The auto-corrected code is a syntax error. ```console % ruby example.rb example.rb:3: syntax error, unexpected local variable or method, expecting `do' or '{' or '(' ....presence || do_something value ```
koic
added a commit
that referenced
this issue
Aug 26, 2019
…_presence [Fix #111] Fix an incorrect autocorrect for `Rails/Presence`
RuboCop Rails 2.3.1 has been released to resolve this issue. Thank you. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
new code will result in syntax error.
Thank
The text was updated successfully, but these errors were encountered: