SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

inclusive_language false positive: mastery contains the term master

Open balavor opened this issue 3 years ago • 1 comments

New Issue Checklist

Describe the bug

A false positive case for the master word when we actually use mastery:

enum Category {
    case productivity
    case mastery
    // ...
}

It is also triggered for all words containing master, like bushmaster or headmaster. The last two a pretty rare to be used inside of a codebase, however, the mastery is something that can be used widely to describe some category in the app or skill in the game.

Error example
error: Inclusive Language Violation: Declaration mastery contains the term "master" which is not considered inclusive. (inclusive_language)

balavor avatar Sep 14 '22 09:09 balavor

The inclusive_language rule provides the configuration option override_allowed_terms that exists exactly to exclude these kinds of false-positives. Adding

inclusive_language:
  override_allowed_terms: ["mastery"]

to your .swiftlint.yml file should do the trick.

SimplyDanny avatar Sep 14 '22 20:09 SimplyDanny

@daltonclaybrook I thought the rule had been updated to avoid this kind of false positive?

jpsim avatar Oct 02 '22 15:10 jpsim

@jpsim Yeah, I thought so too. I'll take a look.

daltonclaybrook avatar Oct 02 '22 15:10 daltonclaybrook

@jpsim Okay, this is how we're handling false-positives. We just have a default set of allowed terms. We could add "mastery" to this list, or we could make this rule a little smarter.

daltonclaybrook avatar Oct 02 '22 16:10 daltonclaybrook

The configuration is expressive enough to overcome the issue. In fact, every false-positive can be fixed by configuration easily. I don't see an urgent need for improvement here.

SimplyDanny avatar Oct 02 '22 16:10 SimplyDanny