checkNegatedBoolean

Checks if there are no variables that have negated boolean names such as notValid, is_not_ok. Using such variables in conditional expressions can be confusing and difficult to read and therefore, this check may be enabled. Based on the casing used for variables, this reports variables with names that:

  • Lower Camel casing: Starts with not followed by anything other than a lower case character, or it contains Not followed by anything other than a lower case character.

  • Upper Camel casing: Contains Not followed by anything other than a lower case character.

  • Snake casing: Starts with not_, it contains _not_, or it ends with _not.

By using these settings instead of just looking for not, names such as notation and myNotifier will not be reported as fails of this check.

Configurable parameters

  • VariableCasing (string): This check automatically uses the Casing setting from the checkVariableCasing check to determine how to detect negated boolean variable names. This means that the check on variable casing must be enabled if this check is enabled.

Exemption tag: %@ok<NEGBO>