- (for any language) Many companies are endeavoring to remove potentially racially-charged terms from their products, including in source code and documentation. Such terms can be offensive or just create unease amongst developers and users of a product. Sonar can help with this, by including rules that detect terms such as “blacklist”, “whitelist”, “slave” and “master” used in code.
- snippet of Noncompliant Code:
def apply_blacklist(x, blacklist, whitelist): return [i for i in x if (i in whitelist or i not in blacklist)] def issue_master_command_to_slave(slave, cmd) return os.system(f"ssh {slave} {cmd}")
- snippet of Compilant Code (fixing the above noncompliant code)
def apply_blocklist(x, blocklist, acceptlist): return [i for i in x if (i in acceptlist or i not in blocklist)] def issue_control_command_to_agent(agent, cmd) return os.system(f"ssh {agent} {cmd}")
-
exceptions to the Noncompliant Code, perhaps a school context, e.g. headmaster
-
external references and/or language specifications
-
type : unsure