KT.USE_ANY_OR_NONE_INSTEAD_OF_FIND

Call for null check can be replaced with 'any' or 'none' call

Turn on this rule to flag find calls for null check that can be replaced with any or none call.

Noncompliant Code

Copy
listOf(1, 2, 3).find { it == 4 } != null
listOf(1, 2, 3).find { it == 4 } == null

Compliant Code

Copy
listOf(1, 2, 3).any { it == 4 }
listOf(1, 2, 3).none { it == 4 }

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