if 语句中的 isEmpty、isBlank、isNotEmpty 或 isNotBlank 调用以赋予默认值。
该快速修复会将 if 条件替换为 ifEmpty 或 ifBlank 调用。
示例:
fun test(list: List<Int>): List<Int> {
return if (list.isEmpty()) {
println()
foo()
} else {
list
}
}
在应用快速修复后:
fun test(list: List<Int>): List<Int> {
return list.ifEmpty {
println()
foo()
}
}
此检查仅报告项目或模块的 Kotlin 语言版本是否为 1.3 或更高版本。