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 #5980] Implement safe and safe-auto-correct options #6341
Conversation
c42ced1
to
7b3f510
Compare
7b3f510
to
efb16af
Compare
@@ -117,9 +117,18 @@ def length | |||
@registry.size | |||
end | |||
|
|||
def enabled(config, only) | |||
def enabled(config, only, only_safe = false) |
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.
I thought we had a rule not to do optional boolean params. In general these days we should favour keyword params all the time.
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.
We could write an internal affairs cop to enforce this. Maybe it would be useful to have it public, but disabled by default. The expect_offense
spec helpers takes in an optional argument for a file name. I'm not sure if we have other usages of optional arguments.
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.
I think such a cop should probably be public.
@@ -117,9 +117,18 @@ def length | |||
@registry.size | |||
end | |||
|
|||
def enabled(config, only) | |||
def enabled(config, only, only_safe = false) |
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.
We could write an internal affairs cop to enforce this. Maybe it would be useful to have it public, but disabled by default. The expect_offense
spec helpers takes in an optional argument for a file name. I'm not sure if we have other usages of optional arguments.
@@ -20,7 +20,13 @@ def autocorrect_enabled? | |||
# allow turning off autocorrect on a cop by cop basis | |||
return true unless cop_config | |||
|
|||
cop_config['AutoCorrect'] != false | |||
return false if cop_config['AutoCorrect'] == false |
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.
I guess here some case
might be a bit more readable then the 3 ifs. I'm with the current implementation, though.
One small point from me - we should probably add a couple of lines in the manual about safe/unsafe cops and put some tip that people should probably use Great work overall! |
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.
rake default
. It executes all tests and RuboCop for itself, and generates the documentation.