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 #9957] Add WholeWord configuration to Naming/InclusiveLanguage's FlaggedTerms config #9965

Merged
merged 1 commit into from Aug 4, 2021

Conversation

dvandersluis
Copy link
Member

@dvandersluis dvandersluis commented Jul 30, 2021

This is a naive fix for #9957.

Allows FlaggedTerms to be set up to only match against a whole word (and enables it for slave). This allows false positives like SLAVersion and TeslaVehicle to not be flagged by the cop.

However, we don't have an inflector for identifiers, and this cop is explicitly case insensitive, which means that enabling this will also stop flagging partial word matches like DatabaseSlave. This really only affects class names since database_slave will still be flagged.


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • 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.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@@ -2557,6 +2557,7 @@ Naming/InclusiveLanguage:
- denylist
- block
slave:
WholeWord: true
Copy link
Collaborator

Choose a reason for hiding this comment

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

This can also be named "PreciseMatch" or something like this. Sounds a bit more descriptive to me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or "ExactMatch". I think we use this somewhere else in the config. It'd be best to check, so we stay consistent with ourselves.

Copy link
Member Author

Choose a reason for hiding this comment

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

We have ExactNameMatch in Style/TrivialAccessors but I don't think it exactly fits here. PreciseMatch would be ok with me but also I wanted to indicate that foo_slave would be caught, because it's a different "word". If you like PreciseMatch I'm happy to change it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair point. Let's stick with WholeWord then. Naming is hard.

@bbatsov bbatsov merged commit 52805b6 into rubocop:master Aug 4, 2021
@dvandersluis dvandersluis deleted the issue/9957 branch September 14, 2021 16: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.

False positives for inclusive language
2 participants