A method has more return statements than the configured maximum
What it finds
Many exits make it hard to see what a method guarantees when it ends, and easy to skip a step on one of the paths. Returns in lambdas and local functions are not counted. The maximum is the parameter max_returns, 5 by default.
From the rule's source, many_returns.rs.
class Exits{ int Many(int a)tx0 reports: Many has 6 return statements, more than 5 { if (a == 1) return 1; if (a == 2) return 2; if (a == 3) return 3; if (a == 4) return 4; if (a == 5) return 5; return 0; }} 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/csharp:many-returns" = "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/csharp:many-returns] reason="..."tx0 explain tx0/csharp:many-returns shows the same in the terminal. Found a false positive? Report it.