Double negatives (DoubleNegatives)¶
Type | Scope | Severity | Activated by default |
Minutes to fix |
Tags |
---|---|---|---|---|---|
Code smell |
BSL OS |
Major |
Yes |
3 |
brainoverload badpractice |
Description¶
Using double negatives makes the code harder to understand and can lead to errors when the developer mentally computes False instead of True, or vice versa. It is recommended to replace double negatives with conditional expressions that directly express the author's intentions.
Examples¶
Incorrect¶
If Not ValueTable.Find(SearchValue, "Column") <> Undefined Then
// Do the action
EndIf;
Correct¶
If ValueTable.Find(LookupValue, "Column") = Undefined Then
// Perform action
EndIf;
Sources¶
- Source: Remove double negative
Snippets¶
Diagnostic ignorance in code¶
// BSLLS:DoubleNegatives-off
// BSLLS:DoubleNegatives-on
Parameter for config¶
"DoubleNegatives": false