Condition of 'if' expression is constant
Reports if
expressions that have true
or false
constant literal condition and can be simplified.
While occasionally intended, this construction is confusing and often the result of a typo or previous refactoring.
Example:
fun example() {
if (true) {
throw IllegalStateException("Unexpected state")
}
}
The quick-fix removes the if
condition:
fun example() {
throw IllegalStateException("Unexpected state")
}
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Kotlin, @snapshot@ |
Last modified: 13 July 2023