KT.EQUALS_ALWAYS_RETURNS_TRUE_OR_FALSE

Method equals() always return true or false

Reports equals() methods which will always return true or false. Equals methods should always report if some other object is equal to the current object. See the Kotlin documentation for Any.equals(other: Any?): https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/equals.html

Noncompliant Code

Copy
override fun equals(other: Any?): Boolean {
  return true
}

Compliant Code

Copy
override fun equals(other: Any?): Boolean {
    return this === 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