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 #8372] Fix Lint/RedundantCopEnableDirective autocorrection not removing empty # rubocop:enable comments #8745

Conversation

dvandersluis
Copy link
Member

Second half of the fix for #8372.

Lint/RedundantCopEnableDirective now determines what directive comments are no longer necessary and removes them outright (ie. when all the cops being enabled are redundant).

The CommentConfig class had quite a bit going on in it so I extracted a new class I called RuboCop::DirectiveComment to encapsulate some logic about determining what cops are present in a directive comment, which Lint/RedundantCopEnableDirective uses to determine if the entire comment should be removed. There probably is more refactoring that could be done here, but I kept it simple for now.


Before submitting the PR make sure the following are checked:

  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new code introduces user-observable changes. See changelog entry format.
  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Run bundle exec rake default. It executes all tests and RuboCop for itself, and generates the documentation.

@dvandersluis dvandersluis force-pushed the fix-redundant-cop-enable-directive-autocomplete branch from 00cbd16 to 4b0d62c Compare September 18, 2020 01:28
…ion not removing empty `# rubocop:enable` comments.

Added `RuboCop::DirectiveComment` to encapsulate some logic about determining whether a rubocop directive comment should be removed (if the cops in it are all redundant).
@dvandersluis dvandersluis force-pushed the fix-redundant-cop-enable-directive-autocomplete branch from 4b0d62c to 9142214 Compare September 22, 2020 16:19
@bbatsov bbatsov merged commit c21be8f into rubocop:master Sep 23, 2020
@bbatsov
Copy link
Collaborator

bbatsov commented Sep 23, 2020

Thanks!

@dvandersluis dvandersluis deleted the fix-redundant-cop-enable-directive-autocomplete branch January 18, 2021 20:39
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

2 participants