equals is declared with a parameter other than Any?, which overloads instead of overriding
What it finds
fun equals(other: Point): Boolean declares a new function next to equals(other: Any?). ==, collections and every generic code call the inherited one, which ignores it.
From the rule's source, equals_overload.rs.
class Point(val x: Int) { fun equals(other: Point): Boolean = other.x == xtx0 reports: equals(Point) overloads equals(Any?) override fun equals(other: Any?): Boolean = other is Point && equals(other) override fun hashCode() = x} 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:
[rules]
"tx0/kotlin:equals-with-narrow-parameter" = "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:equals-with-narrow-parameter] reason="..."tx0 explain tx0/kotlin:equals-with-narrow-parameter shows the same in the terminal. Found a false positive? Report it.