Size check can be replaced with 'isNotEmpty()'
Reports size checks of Collections/Array/String
that should be replaced with isNotEmpty()
.
Using isNotEmpty()
makes your code simpler.
The quick-fix replaces the size check with isNotEmpty()
.
Example:
fun foo() {
val arrayOf = arrayOf(1, 2, 3)
arrayOf.size > 0
}
After the quick-fix is applied:
fun foo() {
val arrayOf = arrayOf(1, 2, 3)
arrayOf.isNotEmpty()
}
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Kotlin, @snapshot@ |
Last modified: 13 July 2023