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
autocorrect removes negation #6860
Labels
Comments
In case useful, a more minimal repro: x.select {|y| not y.z} is autocorrected to x.select(&:z) using rubocop defaults |
The comment #6860 (comment) is so helpful to me. thank you! @dduugg I believe that the problem is that file:
auto-correct:
corrected badly:
|
8 tasks
hoshinotsuyoshi
added a commit
to hoshinotsuyoshi/rubocop
that referenced
this issue
Apr 22, 2019
…hods` and `Style/Not`. Prevent conflict problem like below: file: ``` x.select { |y| not y.z } ``` auto-correct: ``` $ bundle exec rubocop -a c.rb --only Style/InverseMethods,Style/Not Inspecting 1 file C Offenses: c.rb:1:1: C: [Corrected] Style/InverseMethods: Use reject instead of inverting select. x.select { |y| not y.z } ^^^^^^^^^^^^^^^^^^^^^^^^ c.rb:1:1: C: [Corrected] Style/InverseMethods: Use select instead of inverting reject. x.reject { |y| !y.z } ^^^^^^^^^^^^^^^^^^^^^ c.rb:1:16: C: [Corrected] Style/Not: Use ! instead of not. x.select { |y| not y.z } ^^^ 1 file inspected, 3 offenses detected, 3 offenses corrected ``` corrected badly: ``` x.select { |y| y.z } ```
bbatsov
pushed a commit
that referenced
this issue
Apr 22, 2019
…nd `Style/Not`. Prevent conflict problem like below: file: ``` x.select { |y| not y.z } ``` auto-correct: ``` $ bundle exec rubocop -a c.rb --only Style/InverseMethods,Style/Not Inspecting 1 file C Offenses: c.rb:1:1: C: [Corrected] Style/InverseMethods: Use reject instead of inverting select. x.select { |y| not y.z } ^^^^^^^^^^^^^^^^^^^^^^^^ c.rb:1:1: C: [Corrected] Style/InverseMethods: Use select instead of inverting reject. x.reject { |y| !y.z } ^^^^^^^^^^^^^^^^^^^^^ c.rb:1:16: C: [Corrected] Style/Not: Use ! instead of not. x.select { |y| not y.z } ^^^ 1 file inspected, 3 offenses detected, 3 offenses corrected ``` corrected badly: ``` x.select { |y| y.z } ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With file containing:
Running autocorrect:
Ends up losing the negation in the output:
The text was updated successfully, but these errors were encountered: