Kotlin
Condition of 'if' expression is constant
Info
New
Last modified: 03 December 2024 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")
}
- 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.
ConstantConditionIf
Inspection Details | |
---|---|
By default bundled with: | |
Can be installed with plugin: | Kotlin, 243.23126-IJ |
Thanks for your feedback!
Was this page helpful?