Inspectopedia Help

Verbose nullability and emptiness check

Reports combination of null and emptiness checks that can be simplified into a single check.

The quick-fix replaces highlighted checks with a combined check call, such as isNullOrEmpty().

Example:

fun test(list: List<Int>?) { if (list == null || list.isEmpty()) { println("List is empty!") } else { println(list.joinToString()) } }

After the quick-fix is applied:

fun test(list: List<Int>?) { if (list.isNullOrEmpty()) { println("List is empty!") } else { println(list.joinToString()) } }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023