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() } }
fun foo(arg: Boolean): Int { if (arg) return 0 someCode() }

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Kotlin, 241.14841-IJ

Last modified: 12 March 2024