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
[Fix #6860] Prevent auto-correct confliction of Style::InverseMethods and Style::Not #6951
[Fix #6860] Prevent auto-correct confliction of Style::InverseMethods and Style::Not #6951
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! 🚀
CHANGELOG.md
Outdated
@@ -18,6 +18,7 @@ | |||
* [#6946](https://github.com/rubocop-hq/rubocop/pull/6946): Allow `Rails/ReflectionClassName` to use string interpolation for `class_name`. ([@r7kamura][]) | |||
* [#6778](https://github.com/rubocop-hq/rubocop/issues/6778): Fix a false positive in `Style/HashSyntax` cop when a hash key is an interpolated string and EnforcedStyle is ruby19_no_mixed_keys. ([@tatsuyafw][]) | |||
* [#6902](https://github.com/rubocop-hq/rubocop/issues/6902): Fix a bug where `Naming/RescuedExceptionsVariableName` would handle an only first rescue for multiple rescue groups. ([@tatsuyafw][]) | |||
* [#6860](https://github.com/rubocop-hq/rubocop/issues/6860): Prevent auto-correct confliction of Style::InverseMethods and Style::Not. ([@hoshinotsuyoshi][]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nits:
"confliction" -> "conflict"
"Style::InverseMethods" -> "Style/InverseMethods
"
"Style::Not" -> "Style/Not
"
🙇
e785199
to
0656f7d
Compare
CHANGELOG.md
Outdated
@@ -18,6 +18,7 @@ | |||
* [#6946](https://github.com/rubocop-hq/rubocop/pull/6946): Allow `Rails/ReflectionClassName` to use string interpolation for `class_name`. ([@r7kamura][]) | |||
* [#6778](https://github.com/rubocop-hq/rubocop/issues/6778): Fix a false positive in `Style/HashSyntax` cop when a hash key is an interpolated string and EnforcedStyle is ruby19_no_mixed_keys. ([@tatsuyafw][]) | |||
* [#6902](https://github.com/rubocop-hq/rubocop/issues/6902): Fix a bug where `Naming/RescuedExceptionsVariableName` would handle an only first rescue for multiple rescue groups. ([@tatsuyafw][]) | |||
* [#6860](https://github.com/rubocop-hq/rubocop/issues/6860): Prevent auto-correct conflict of Style/InverseMethods and Style/Not. ([@hoshinotsuyoshi][]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cop names are preferably quoted :-)
-Prevent auto-correct conflict of Style/InverseMethods and Style/Not. ([@hoshinotsuyoshi][])
+Prevent auto-correct conflict of `Style/InverseMethods` and `Style/Not`. ([@hoshinotsuyoshi][])
…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 } ```
0656f7d
to
4e2b19d
Compare
Thanks! |
Fix #6860.
Prevent confliction problem like below:
file:
auto-correct:
corrected badly:
Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).and description in grammatically correct, complete sentences.
bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.