Inspectopedia 2025.2 Help

'if' condition can be replaced with lambda call

Reports isEmpty, isBlank, isNotEmpty, or isNotBlank calls in an if statement to assign a default value.

The quick-fix replaces the if condition with ifEmpty or ifBlank calls.

Example:

fun test(list: List<Int>): List<Int> { return if (list.isEmpty()) { println() foo() } else { list } }

After the quick-fix is applied:

fun test(list: List<Int>): List<Int> { return list.ifEmpty { println() foo() } }

Locating this inspection

By ID

Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

ReplaceIsEmptyWithIfEmpty
Via Settings dialog

Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.

Settings or Preferences | Editor | Inspections | Kotlin | Style issues

This inspection only reports if the Kotlin language version of the project or module is 1.3 or higher.

Suppressing Inspection

You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:

//noinspection ReplaceIsEmptyWithIfEmpty

More detailed instructions as well as other ways and options that you have can be found in the product documentation:

Inspection Details

By default bundled with:

IntelliJ IDEA 2025.2, Qodana for JVM 2025.2,

Last modified: 18 September 2025