Inclusive Class
ID |
php.inclusive_class |
Severity |
info |
Remediation Complexity |
trivial |
Remediation Risk |
medium |
Remediation Effort |
low |
Resource |
Code Smell |
Language |
Php |
Tags |
code_smell, inclusive |
Description
Reports a class, interface, trait or enum whose name contains a non-inclusive term such as
blacklist, whitelist, master or slave. The check is a case-insensitive substring test,
so compound names like MasterController or SlaveNode are flagged.
Rationale
Type names are part of a project’s public vocabulary: they appear in autocompletion, stack traces, documentation and every file that uses the type. Terms like master/slave or whitelist/blacklist carry exclusionary connotations and have widely-adopted neutral replacements (primary/replica, allow-list/deny-list) that read at least as clearly. Choosing inclusive names keeps the codebase welcoming without any loss of meaning.
<?php
class MasterController {} // FLAW - "master" is non-inclusive
interface SlaveNode {} // FLAW - "slave" is non-inclusive
class PrimaryController {} // OK - neutral replacement
interface ReplicaNode {} // OK - neutral replacement
Remediation
Rename the type to an inclusive equivalent: master becomes primary/main, slave becomes
replica/secondary, whitelist becomes allowList, and blacklist becomes denyList. Use
an IDE rename refactoring so all references update together.