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 #9175] Fix status for offenses that are not correctable. #9190

Merged
merged 1 commit into from Dec 8, 2020

Conversation

marcandre
Copy link
Contributor

@marcandre marcandre commented Dec 8, 2020

This addresses a few things:

  1. Calling add_offense or add_offense { |corrector| # don't auto-correct } should be handled the same way. An empty corrector is now replaced by nil.
  2. Tweaks how the status is handled. Status :uncorrected is reserved for cases where there is a corrector but it is not applied.
  3. Old style cops' auto_correct method is now called even when run without auto-correction. This way we can know if they can auto-correct or not. It also simplifies logic.

I should have done 3) during my refactor (I don't see how it could be incompatible)

This addresses a few things:
1) Calling `add_offense` or `add_offense { |corrector| # don't auto-correct }` should be handled the same way. An empty corrector is now replaced by `nil`.
2) Tweaks how the status is handled. Status `:uncorrected` is reserved for cases where there is a corrector but it is not applied.
3) Old style cops' `auto_correct` method is now called even when run without auto-correction. This way we can know if they can auto-correct or not. It also simplifies logic.

I should have done 3) during my refactor (I don't see how it could be incompatible)
@bbatsov
Copy link
Collaborator

bbatsov commented Dec 8, 2020

Looks good to me.

Copy link
Member

@dvandersluis dvandersluis left a comment

Choose a reason for hiding this comment

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

Cleaner than my solution. :shipit:

@dvandersluis
Copy link
Member

Now that #9187 is merged the changed tests might fail now because they shouldn't be marked as [Correctable] with this PR. Also probably makes sense to have tests specifically for not-correctable and for unsafe-correctable like I did in #9176.

@bbatsov bbatsov merged commit 24765a0 into rubocop:master Dec 8, 2020
dvandersluis added a commit to dvandersluis/rubocop that referenced this pull request Dec 8, 2020
@marcandre marcandre deleted the autocorrectable branch December 8, 2020 18:09
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.

None yet

3 participants