size, length or count() is compared with zero instead of using isEmpty()

tx0/kotlin:size-compared-with-zerostrictwarningstyle/conventionsdepth faststyle

What it finds

items.size == 0 and name.length > 0 say items.isEmpty() and name.isNotEmpty() in more words, and count() may walk a whole sequence to answer.

From the rule's source, size_zero_check.rs.

Example from the rule's tests
fun check(items: List<Int>, name: String): Boolean {    if (items.size == 0) return falsetx0 reports: tests for emptiness    if (name.length > 0) return truetx0 reports: tests for emptiness    if (0 != items.count()) return truetx0 reports: tests for emptiness    return items.size > 1}
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 strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/kotlin:size-compared-with-zero" = "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:size-compared-with-zero] reason="..."

tx0 explain tx0/kotlin:size-compared-with-zero shows the same in the terminal. Found a false positive? Report it.