Supported case when result variable initialization is not right before the loop
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
fun foo(list: List<String>) {
|
||||
var found = false
|
||||
println("Starting the search")
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
fun foo(list: List<String>) {
|
||||
println("Starting the search")
|
||||
val <caret>found = list.any { it.length > 0 }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
fun foo(list: List<String>, p: Int) {
|
||||
var found: Boolean
|
||||
if (p > 0) {
|
||||
found = false
|
||||
println("Starting the search")
|
||||
<caret>for (s in list) {
|
||||
if (s.length > 0) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'any{}'"
|
||||
fun foo(list: List<String>, p: Int) {
|
||||
var found: Boolean
|
||||
if (p > 0) {
|
||||
println("Starting the search")
|
||||
<caret>found = list.any { it.length > 0 }
|
||||
}
|
||||
else {
|
||||
found = true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.map{}'"
|
||||
import java.util.*
|
||||
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val result = ArrayList<Int>()
|
||||
var i = 0
|
||||
<caret>for (s in list) {
|
||||
if (s.length > i) {
|
||||
result.add(s.length)
|
||||
}
|
||||
i++
|
||||
}
|
||||
return result
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filterIndexed{}.map{}'"
|
||||
import java.util.*
|
||||
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val <caret>result = list
|
||||
.filterIndexed { i, s -> s.length > i }
|
||||
.map { it.length }
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user