-
Notifications
You must be signed in to change notification settings - Fork 1.9k
SC2335
James edited this page Dec 1, 2025
·
5 revisions
and other binary operators such as
-
=and!=(string) -
-leand-gt, and so forth (arithmetic)
This is an optional rule, which means that it has a special "long name" and is not enabled by default. See the optional page for more details. In short, you have to enable it with the long name instead of the "SC" code like you would with a normal rule:
enable=avoid-negated-conditions # SC2335
if [ ! "$var" -eq 1 ]; then :; fi
if ! [ "$var" = foo ]; then :; fiif [ "$var" -ne 1 ]; then :; fi
if [ "$var" != foo ]; then :; fiDouble negation of such binary operators is unnecessary.
This is a stylistic issue that does not affect correctness. If you prefer the original expression, you can Ignore it with a directive or flag.
This rule is not applied to the followings:
-
<and>(lexicographical) -
-ntand-ot(file timestamp) -
=~(regular expression)