Pattern: Use of ?: emptyList()
Issue: -
Detects ?: emptyList()
that can be replaced with orEmpty()
call.
Example of incorrect code:
fun test(x: List<Int>?, s: String?) {
val a = x ?: emptyList()
val b = s ?: ""
}
Example of correct code:
fun test(x: List<Int>?, s: String?) {
val a = x.orEmpty()
val b = s.orEmpty()
}