Simplifiable call inspection: add filter -> filterNotNull replacement

Related to KT-30501
This commit is contained in:
Mikhail Glukhikh
2019-05-06 12:19:39 +03:00
parent 4a5cbe0443
commit 8913755e11
15 changed files with 161 additions and 11 deletions
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String?>) {
list.<caret>filter({ it != null })
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String?>) {
list.filterNotNull()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
// PROBLEM: none
fun test(map: Map<String?, String?>) {
map.<caret>filter { (k, v) -> k != null && v != null }
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String?>) {
list.<caret>filter { arg -> arg != null }
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String?>) {
list.filterNotNull()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
// PROBLEM: none
fun test(list: List<Boolean>) {
list.<caret>filter { it }
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String?>) {
list.<caret>filter { it !== null }
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String?>) {
list.filterNotNull()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
// PROBLEM: none
fun test(map: Map<String?, String?>) {
map.<caret>filter { it != null }
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String?>) {
list.<caret>filter { null != it }
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String?>) {
list.filterNotNull()
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String?>) {
list.<caret>filter { it != null }
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String?>) {
list.filterNotNull()
}