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

Fix bug that would report offenses being auto-corrected when they were not #1829

Merged
merged 1 commit into from
Apr 25, 2015

Conversation

rrosenblum
Copy link
Contributor

In fixing the some bugs in the Sample cop, I noticed that some offenses were reporting that they had been corrected when they were not. I found out that I should be using fail CorrectionNotPossible instead of return in autocorrect when the error cannot be corrected.

@@ -36,7 +36,8 @@ def autocorrect(node)
_receiver, _method, params, selector = *node
_receiver, _method, params, selector = *node.parent if params.nil?

return if params && RANGE_TYPES.include?(params.type)
fail CorrectionNotPossible if params &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert this to a regular if or extract some helper method.

@rrosenblum
Copy link
Contributor Author

I have extracted a method for the if statement

bbatsov added a commit that referenced this pull request Apr 25, 2015
Fix bug that would report offenses being auto-corrected when they were not
@bbatsov bbatsov merged commit b0e0995 into rubocop:master Apr 25, 2015
@rrosenblum rrosenblum deleted the correction_bug branch April 25, 2015 02:04
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