A unary !, - or + is applied twice in a row and cancels out
What it finds
!!ready and - -n apply an operator twice, which cancels out: the value is the operand itself. Usually one operator was typed twice, or the operand was meant to change. ~~x is left alone: code compiled to JavaScript uses it to force a 32-bit integer.
From the rule's source, doubled_unary.rs.
class Flags { boolean check(boolean ready, int mask, int n) { boolean a = !!ready;tx0 reports: !!ready applies the same operator twice int b = ~~mask; int c = - -n;tx0 reports: - -n applies the same operator twice int d = -(-n + 1); return a || !ready; }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/java:doubled-unary" = "off"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/java:doubled-unary] reason="..."tx0 explain tx0/java:doubled-unary shows the same in the terminal. Found a false positive? Report it.