Inspectopedia Help

Redundant 'if' statement

Reports if statements which can be simplified to a single statement.

Example:

fun test(): Boolean { if (foo()) { return true } else { return false } }

After the quick-fix is applied:

fun test(): Boolean { return foo() }

Inspection options

Option

Type

Default

Ignore chained 'if' statements

Checkbox

true

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023