KT.NULLABLE_BOOLEAN_CHECK

Nullable boolean check

Detects nullable boolean checks which use an elvis expression ?: rather than equals ==. Per the Kotlin coding conventions converting a nullable boolean property to non-null should be done via != false or == true rather than ?: true or ?: false (respectively).

Noncompliant Code

Copy
value ?: true
value ?: false

Compliant Code

Copy
value != false
value == true

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