Pattern: Use of ?:
Issue: -
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).
Example of incorrect code:
value ?: true
value ?: false
Example of correct code:
value != false
value == true