Control statements are nested deeper than the limit
What it finds
Control statements nested deep inside each other are hard to follow: to understand the innermost one, a reader has to keep every condition around it in mind. Returning early, or moving the inner part into a method of its own, flattens the code.
The depth counts if, for, while, do, switch, try and synchronized around a statement within one method; an if after else belongs to its chain and does not count again. The statement that goes past the parameter max-depth, 4 by default, is reported, and the statements inside it are not reported again.
From the rule's source, deep_nesting.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:deep-nesting" = "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:deep-nesting] reason="..."tx0 explain tx0/java:deep-nesting shows the same in the terminal. Found a false positive? Report it.