-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Return nil from autocorrect? if cop does not support autocorrection #1712
Conversation
@@ -5,7 +5,9 @@ module Cop | |||
# This module encapsulates the logic for autocorrect behaviour for a cop | |||
module AutocorrectLogic | |||
def autocorrect? | |||
@options[:auto_correct] && support_autocorrect? && autocorrect_enabled? | |||
return nil unless support_autocorrect? |
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.
Boolean methods should return either true
or false
. Returning anything else is unexpected/uncommon.
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.
Agreed. It did return nil
previously though, if the option wasn't given.
I will improve it tomorrow. |
@@ -74,6 +74,60 @@ | |||
expect(cop.offenses.first.cop_name).to eq('Style/For') | |||
end | |||
|
|||
describe 'corrected' do |
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.
This description seems a bit misleading to me.
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.
LOL forgot to change it. Made a better one now.
You'll have to rebase. |
true = corrected false = not corrected nil = not applicable (cop cannot autocorrect code)
Rebased. |
Return nil from autocorrect? if cop does not support autocorrection
👍 |
More meaningful values of offenses'
corrected
attribute:nil
— the cop does not support autocorrection at all;false
— the cop could autocorrect this offense, but didn't do it for one reason or another;true
— the cop has autocorrected this offense.