A comparison or type check is a statement of its own, and its result is dropped

tx0/kotlin:comparison-result-unusedrecommendedwarningreliability/api-misusedepth fastbug

What it finds

a == b on a line of its own computes a Boolean and drops it. It is usually an assignment written with ==, or an assertion that lost its check or assert.

From the rule's source, discarded_comparison.rs.

Example from the rule's tests
fun update(a: Int, b: Int, items: List<Int>): Boolean {    var total = a    total == btx0 reports: the result of total == b is not used    a is Inttx0 reports: the result of a is Int is not used    if (a > 1) {        a < btx0 reports: the result of a < b is not used    }    val ok = items.any { it == a }    return total == b}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

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:comparison-result-unused" = "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:comparison-result-unused] reason="..."

tx0 explain tx0/kotlin:comparison-result-unused shows the same in the terminal. Found a false positive? Report it.