Code that can never run
What it finds
Statements after return, goto, break, continue, fallthrough or panic(...) in the same block never run. A labelled statement is reachable through its label and ends the unreachable part.
From the rule's source, unreachable_code.rs.
package p func h(n int) int { if n > 0 { return 1 n++tx0 reports: never reached } for { break n--tx0 reports: never reached n-- } switch n { case 1: panic("one") n = 2tx0 reports: never reached case 2: fallthrough default: n = 3 } goto end n = 4tx0 reports: never reachedend: return n} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/go:unreachable-code" = "off"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/go:unreachable-code] reason="..."tx0 explain tx0/go:unreachable-code shows the same in the terminal. Found a false positive? Report it.