A method's branches, weighted by how deep they are nested, add up past the limit
What it finds
Branches inside branches cost a reader more than branches one after another. This measure weighs each branch by how deep it is nested:
- each if, conditional expression, switch, loop and catch adds one, plus one for every such structure and lambda around it; - each else, and each else if, adds one; - each run of one logical operator adds one, so a && b && c adds one and a && b || c adds two; - each break or continue to a label adds one.
A method above the parameter max, 15 by default, is reported.
From the rule's source, weighted_complexity.rs.
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/java:nesting-weighted-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/java:nesting-weighted-complexity] reason="..."tx0 explain tx0/java:nesting-weighted-complexity shows the same in the terminal. Found a false positive? Report it.