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

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Kotlin, 241.16690-IJ

Last modified: 29 April 2024