A statement follows a return, throw, break or continue and never runs
What it finds
Code after return, throw, break or continue in the same block never runs. It is either dead and can go, or the jump was meant to be conditional. Only the first unreachable statement of a block is reported.
From the rule's source, unreachable_code.rs.
fun check(x: Int): Int { if (x < 0) { throw IllegalArgumentException("negative") println("never")tx0 reports: this code never runs: it follows throw } for (i in 0..x) { if (i == 3) { break println("never")tx0 reports: this code never runs: it follows break } } listOf(1).forEach { return@forEach println(it)tx0 reports: this code never runs: it follows return } return x} 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/kotlin: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/kotlin:unreachable-code] reason="..."tx0 explain tx0/kotlin:unreachable-code shows the same in the terminal. Found a false positive? Report it.