An if, else, loop, init, try or finally block is empty

tx0/kotlin:empty-blockrecommendedwarningmaintainability/dead-codedepth fastsmell

What it finds

An empty block does nothing and usually means that code was lost, or that a condition is checked without consequence. A comment inside saying why the block is empty is accepted. Empty catch blocks have a rule of their own, and empty function bodies are left alone, as they often implement an interface on purpose.

From the rule's source, empty_block.rs.

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:

tx0.toml
[rules]
"tx0/kotlin:empty-block" = "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:empty-block] reason="..."

tx0 explain tx0/kotlin:empty-block shows the same in the terminal. Found a false positive? Report it.