The result of compareTo is tested for equality with a value other than zero

tx0/kotlin:compare-to-exact-valuedefaultwarningreliability/equalitydepth fastbug

What it finds

a.compareTo(b) == 1 assumes that compareTo returns exactly 1 or -1. The contract of Comparable only promises a negative number, zero or a positive number, and many implementations return the difference of two values.

From the rule's source, compare_to_sign.rs.

Example from the rule's tests
fun order(a: String, b: String): Boolean {    if (a.compareTo(b) == 1) return truetx0 reports: compareTo may return any positive number, not only 1    if (-1 == a.compareTo(b)) return falsetx0 reports: any negative number    return a.compareTo(b) == 0 || a.compareTo(b) > 0}
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 in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:compare-to-exact-value" = "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:compare-to-exact-value] reason="..."

tx0 explain tx0/kotlin:compare-to-exact-value shows the same in the terminal. Found a false positive? Report it.