KT.EQUALS_NULL_CALL

Method 'equals()' is called with null parameter

To compare an object with null prefer using ==. This rule detects and reports instances in the code where the equals() method is used to compare a value with null.

Noncompliant Code

Copy
fun isNull(str: String) = str.equals(null)

Compliant Code

Copy
fun isNull(str: String) = str == null

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