Checking that target collection is always the same
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun foo(list: List<MutableCollection<Int>>) {
|
||||
<caret>for (collection in list) {
|
||||
collection.add(collection.size)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
import java.util.ArrayList
|
||||
|
||||
var globalCollection = ArrayList<Int>()
|
||||
|
||||
fun foo(list: List<Collection<Int>>) {
|
||||
<caret>for (collection in list) {
|
||||
globalCollection.add(collection.size)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapTo(){}'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<MutableCollection<Int>>) {
|
||||
var target: MutableCollection<Int>()
|
||||
target = ArrayList<Int>()
|
||||
|
||||
<caret>for (collection in list) {
|
||||
target.add(collection.size)
|
||||
}
|
||||
|
||||
if (target.size > 100) {
|
||||
target = ArrayList<Int>()
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'mapTo(){}'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<MutableCollection<Int>>) {
|
||||
var target: MutableCollection<Int>()
|
||||
<caret>target = list.mapTo(ArrayList<Int>()) { it.size }
|
||||
|
||||
if (target.size > 100) {
|
||||
target = ArrayList<Int>()
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'"
|
||||
// IS_APPLICABLE: false
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'filter{}.mapTo(){}'"
|
||||
import java.util.ArrayList
|
||||
|
||||
fun foo(list: List<String>): List<Int> {
|
||||
val result = ArrayList<Int>()
|
||||
<caret>list
|
||||
.filter { it.length > result.size }
|
||||
.mapTo(result) { it.hashCode() }
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user