A function is harder to follow than the configured maximum, counting nesting and breaks in its flow

tx0/c:nesting-weighted-complexityallwarningmaintainability/complexitydepth fastmaintainability

What it finds

A function that is hard to follow, by a measure of how much a reader has to keep in mind, rather than how many paths there are. tx0 counts:

- 1 for each if, else if, else, switch, loop, conditional expression and goto; - for each if, switch, loop and conditional expression, 1 more for every one of these it is nested in, since nested decisions are harder to follow than ones in a row; - 1 for each run of the same logical operator in a condition, so a && b && c counts 1 and a && b || c counts 2.

The maximum is the parameter max, 25 by default.

From the rule's source, nesting_weighted_complexity.rs.

Turn it on, off or suppress it

The rule runs from the all tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/c: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/c:nesting-weighted-complexity] reason="..."

tx0 explain tx0/c:nesting-weighted-complexity shows the same in the terminal. Found a false positive? Report it.