A condition joins more && and || operators than the configured maximum
What it finds
a && b || c && !d && e || f: a long chain of logical operators is hard to get right and to read; named intermediate values or a helper function say what each part means. The operators of one expression are counted through parentheses and negations, and the maximum is the parameter max, 4 by default.
From the rule's source, boolean_expression_complexity.rs.
int check(int a, int b, int c, int d, int e, int f){ if (a && b || (c && !(d || e)) || f)tx0 reports: this condition joins 5 && and || operators, more than 4 return 1; return a && b && c && d;} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/c:boolean-expression-complexity" = "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/c:boolean-expression-complexity] reason="..."tx0 explain tx0/c:boolean-expression-complexity shows the same in the terminal. Found a false positive? Report it.