Inclusive Functions

ID

go.inclusive_functions

Severity

info

Remediation Complexity

trivial

Remediation Risk

medium

Remediation Effort

low

Resource

Best Practice

Language

Go

Tags

inclusive, naming

Description

Reports function and 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

Function and method names are read at every call site and surface in documentation, profiles and stack traces. 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.

func AddToBlacklist() {}          // FLAW
func IsMaster() bool { return true } // FLAW
func SanityCheck() {}             // FLAW

func AddToDenylist() {}           // OK
func IsPrimary() bool { return true } // OK
func ValidateState() {}           // OK

Remediation

Rename the function or method using an inclusive alternative, for example AddToDenylist instead of AddToBlacklist, or IsPrimary instead of IsMaster.