A statement follows a return, throw, break, continue or goto in the same block and never runs
What it finds
A statement right after a jump in the same block cannot be reached, unless it has a label that a goto targets. Local functions are declarations and may follow a return; they are left alone, as are stray semicolons and a yield break after a throw, which some iterators use to make the method an iterator.
From the rule's source, unreachable_statement.rs.
class Flow{ int Pick(int a) { if (a > 0) { return 1; a = 2;tx0 reports: this statement can never run } return a; int Helper() => 3; }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/csharp:unreachable-statement" = "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:unreachable-statement] reason="..."tx0 explain tx0/csharp:unreachable-statement shows the same in the terminal. Found a false positive? Report it.