Inspection to highlight usages of Collections.sort() and replace them with .sort() method from Kotlin stdlib
#KT-11023 Fixed
This commit is contained in:
committed by
Dmitry Jemerov
parent
4ac870500f
commit
2cdc246a27
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.JavaCollectionsStaticMethodInspection
|
||||
@@ -0,0 +1,7 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
import java.util.Collections
|
||||
|
||||
fun test() {
|
||||
val mutableList = mutableListOf(1, 2)
|
||||
<caret>Collections.fill(mutableList, 3)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
import java.util.Collections
|
||||
|
||||
fun test() {
|
||||
val mutableList = mutableListOf(1, 2)
|
||||
mutableList.fill(3)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
import java.util.Collections
|
||||
|
||||
fun test() {
|
||||
val mutableList = mutableListOf(1, 2)
|
||||
<caret>Collections.reverse(mutableList)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
import java.util.Collections
|
||||
|
||||
fun test() {
|
||||
val mutableList = mutableListOf(1, 2)
|
||||
mutableList.reverse()
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
// PROBLEM: none
|
||||
import java.util.Collections
|
||||
|
||||
fun test() {
|
||||
val list = listOf(1, 2)
|
||||
<caret>Collections.reverse(list)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
import java.util.Collections
|
||||
|
||||
fun test() {
|
||||
val mutableList = mutableListOf(1, 2)
|
||||
<caret>Collections.shuffle(mutableList)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
import java.util.Collections
|
||||
|
||||
fun test() {
|
||||
val mutableList = mutableListOf(1, 2)
|
||||
mutableList.shuffle()
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
import java.util.*
|
||||
|
||||
fun test() {
|
||||
val mutableList = mutableListOf(1, 2)
|
||||
<caret>Collections.shuffle(mutableList, Random(1))
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
import java.util.*
|
||||
|
||||
fun test() {
|
||||
val mutableList = mutableListOf(1, 2)
|
||||
mutableList.shuffle(Random(1))
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
import java.util.Collections
|
||||
|
||||
fun test() {
|
||||
val mutableList = mutableListOf(1, 2)
|
||||
<caret>Collections.sort(mutableList)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
import java.util.Collections
|
||||
|
||||
fun test() {
|
||||
val mutableList = mutableListOf(1, 2)
|
||||
mutableList.sort()
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
// PROBLEM: none
|
||||
import java.util.Collections
|
||||
|
||||
fun test() {
|
||||
val list = listOf(1, 2)
|
||||
<caret>Collections.sort(list)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
import java.util.Collections
|
||||
|
||||
fun test() {
|
||||
val mutableList = mutableListOf(1, 2)
|
||||
<caret>Collections.sort(mutableList, { a, b -> a.compareTo(b) })
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// RUNTIME_WITH_FULL_JDK
|
||||
import java.util.Collections
|
||||
|
||||
fun test() {
|
||||
val mutableList = mutableListOf(1, 2)
|
||||
mutableList.sortWith(Comparator { a, b -> a.compareTo(b) })
|
||||
}
|
||||
Reference in New Issue
Block a user