The process is ended outside main, which skips the caller's cleanup
What it finds
exitProcess(1) or System.exit(1) deep in the code ends the whole program: callers cannot recover, finally blocks do not run, and in a server or a test it takes everything down. Throwing and deciding in main keeps the decision in one place.
From the rule's source, exit_process.rs.
import kotlin.system.exitProcess fun fail(message: String): Nothing { System.err.println(message) exitProcess(1)tx0 reports: exitProcess ends the process outside main} fun main(args: Array<String>) { if (args.isEmpty()) exitProcess(2) System.exit(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/kotlin:exit-outside-main" = "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/kotlin:exit-outside-main] reason="..."tx0 explain tx0/kotlin:exit-outside-main shows the same in the terminal. Found a false positive? Report it.