Skip to content
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

Merged
merged 5 commits into from
Mar 18, 2015
Merged

Return nil from autocorrect? if cop does not support autocorrection #1712

merged 5 commits into from
Mar 18, 2015

Conversation

vassilevsky
Copy link
Contributor

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.

@@ -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?
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@vassilevsky
Copy link
Contributor Author

I will improve it tomorrow.

@@ -74,6 +74,60 @@
expect(cop.offenses.first.cop_name).to eq('Style/For')
end

describe 'corrected' do
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@bbatsov
Copy link
Collaborator

bbatsov commented Mar 18, 2015

You'll have to rebase.

@vassilevsky
Copy link
Contributor Author

Rebased.

bbatsov added a commit that referenced this pull request Mar 18, 2015
Return nil from autocorrect? if cop does not support autocorrection
@bbatsov bbatsov merged commit d5dfffa into rubocop:master Mar 18, 2015
@bbatsov
Copy link
Collaborator

bbatsov commented Mar 18, 2015

👍

@vassilevsky vassilevsky deleted the corrected branch March 19, 2015 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants