Inclusive Variable
ID |
csharp.inclusive_variable |
Severity |
info |
Remediation Complexity |
trivial |
Remediation Risk |
medium |
Remediation Effort |
low |
Resource |
Best Practice |
Language |
CSharp |
Tags |
inclusive, naming |
Description
Reports field, property, local-variable and parameter 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
Identifiers are read far more often than they are written and shape how developers reason about code. Non-inclusive terminology carries unintended connotations, and neutral alternatives are usually clearer. Preferring inclusive names is a low-cost habit that keeps the codebase welcoming and precise.
private List<string> blacklist; // FLAW
public string MasterKey { get; set; } // FLAW
void Connect(string slaveHost) { } // FLAW
private List<string> denylist; // OK
public string PrimaryKey { get; set; } // OK
void Connect(string replicaHost) { } // OK
Remediation
Rename the field, property, variable or parameter using an inclusive alternative, for example
denylist instead of blacklist, or replicaHost instead of slaveHost.