KT.WRONG_EQUALS_TYPE_PARAMETER

MEthod 'equals()' takes in a wrongly typed parameter

Reports equals() methods which take in a wrongly typed parameter. Correct implementations of the equals() method should only take in a parameter of type Any? See: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/equals.html

Noncompliant Code

Copy
class Foo {

    fun equals(other: String): Boolean {
        return super.equals(other)
    }
}

Compliant Code

Copy
class Foo {

    fun equals(other: Any?): Boolean {
        return super.equals(other)
    }
}

The content on this page is adapted from the Detekt Docs. Copyright ©2022 The Detekt Team. All rights reserved. https://detekt.dev/comments.html