Inspectopedia Help

Simplifiable 'when'

Reports when expressions with the constant true or false branches.

Simplify "when" quick-fix can be used to amend the code automatically.

Examples:

fun redundant() { when { // <== redundant, quick-fix simplifies the when expression to "println("true")" true -> println("true") else -> println("false") } }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023