Introduce "Redundant 'asSequence' call" inspections

#KT-35893 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-01-14 17:54:21 +09:00
committed by igoriakovlev
parent e2c3455445
commit afd544cbab
18 changed files with 183 additions and 5 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.collections.RedundantAsSequenceInspection
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String>) {
list/*comment*/.<caret>asSequence().last()
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String>) {
list/*comment*/.last()
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun test(list: List<String>) {
list
// comment
.<caret>asSequence()
.max()
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
fun test(list: List<String>) {
list
// comment
.max()
}
@@ -0,0 +1,5 @@
// PROBLEM: none
// WITH_RUNTIME
fun test(list: List<String>) {
list.<caret>sorted().first()
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String>?) {
list?.<caret>asSequence()?.first()
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String>?) {
list?.first()
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String>) {
list.<caret>asSequence().all { it.isBlank() }
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(list: List<String>) {
list.all { it.isBlank() }
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(set: Set<String>) {
set.<caret>asSequence().any { it.isBlank() }
}
@@ -0,0 +1,4 @@
// WITH_RUNTIME
fun test(set: Set<String>) {
set.any { it.isBlank() }
}