Kotlin
'when' has only 'else' branch and can be simplified
Info
New
Last modified: 03 December 2024 Reports when
expressions with only an else
branch that can be simplified.
Simplify expression quick-fix can be used to amend the code automatically.
Example:
fun redundant() {
val x = when { // <== redundant, the quick-fix simplifies the when expression to "val x = 1"
else -> 1
}
}
- 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.
WhenWithOnlyElse
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Kotlin, 243.23126-IJ |
Thanks for your feedback!
Was this page helpful?