equals uses == on this, or toString uses this in a string, and calls itself forever

tx0/kotlin:self-recursive-equals-or-tostringrecommendederrorreliability/equalitydepth fastbug

What it finds

override fun equals(other: Any?) = this == other calls equals again, and so does "$this" in toString, until the stack overflows. Comparing the properties, or === for identity, and building the string from the properties, ends.

From the rule's source, self_recursive_member.rs.

Example from the rule's tests
class Name(val value: String) {    override fun equals(other: Any?): Boolean = this == othertx0 reports: equals calls itself here    override fun hashCode() = value.hashCode()    override fun toString() = "Name($this)"tx0 reports: toString calls itself here} class Fine(val value: String) {    override fun equals(other: Any?): Boolean = this === other || other is Fine && other.value == value    override fun hashCode() = value.hashCode()    override fun toString() = "Fine($value)"}
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:self-recursive-equals-or-tostring" = "error"

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:self-recursive-equals-or-tostring] reason="..."

tx0 explain tx0/kotlin:self-recursive-equals-or-tostring shows the same in the terminal. Found a false positive? Report it.