Pattern: Missing use of isNullOrEmpty()
Issue: -
Detects null or empty checks that can be replaced with isNullOrEmpty()
call.
Example of incorrect code:
fun foo(x: List<Int>?) {
if (x == null || x.isEmpty()) return
}
fun bar(x: List<Int>?) {
if (x == null || x.count() == 0) return
}
fun baz(x: List<Int>?) {
if (x == null || x.size == 0) return
}
Example of correct code:
if (x.isNullOrEmpty()) return