Inspectopedia Help

Redundant 'else' in 'if'

Reports redundant else in if with return

Example:

fun foo(arg: Boolean): Int { if (arg) return 0 else { // This else is redundant, code in braces could be just shifted left someCode() } }

After the quick-fix is applied:

fun foo(arg: Boolean): Int { if (arg) return 0 someCode() }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023