A negation with ! is compared with a value that is not a truth value
What it finds
!x == y: ! binds tighter than ==, so this compares !x, which is 0 or 1, with y. Usually !(x == y), that is x != y, was meant.
Left alone are comparisons whose other side is a truth value too, or may be: !a == !b, !x == 0, !x == true, a comparison, a logical operation, a variable declared bool, and anything whose type the file does not show. So is !!x, which makes a truth value of x on purpose. Some code compares !x with an integer flag on purpose, which is why the rule is not in the default set.
From the rule's source, not_precedence.rs.
Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/cpp:not-precedence" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/cpp:not-precedence] reason="..."tx0 explain tx0/cpp:not-precedence shows the same in the terminal. Found a false positive? Report it.