Inclusive Function
ID |
csharp.inclusive_function |
Severity |
info |
Remediation Complexity |
trivial |
Remediation Risk |
medium |
Remediation Effort |
low |
Resource |
Best Practice |
Language |
CSharp |
Tags |
inclusive, naming |
Description
Reports method names that contain a non-inclusive term such as blacklist, whitelist,
master, slave, grandfather, dummy or sanity. The term list is configurable through
the terms property.
Rationale
Method names are read at every call site and surface in IntelliSense, stack traces and documentation. Non-inclusive terminology carries unintended connotations, and neutral alternatives are usually clearer. Preferring inclusive names is a cheap habit that keeps an API welcoming and unambiguous.
public void AddToBlacklist() { } // FLAW
public bool IsMaster() { } // FLAW
public void SanityCheck() { } // FLAW
public void AddToDenylist() { } // OK
public bool IsPrimary() { } // OK
public void ValidateState() { } // OK
Remediation
Rename the method using an inclusive alternative, for example AddToDenylist instead of
AddToBlacklist, or IsPrimary instead of IsMaster.