Suggest to replace manual range with explicit indices or iterable
#KT-14344 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
8cda5cb849
commit
3451c60f93
+1
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.ReplaceManualRangeWithIndicesCallsInspection
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
// PROBLEM: none
|
||||
fun test(args: Array<Int>) {
|
||||
val x = arrayOf<String>()
|
||||
for (index in ar<caret>gs) {
|
||||
val out = x[index]
|
||||
}
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(args: Array<String>) {
|
||||
for (index in 0..ar<caret>gs.size - 1) {
|
||||
args[index] = "Hello"
|
||||
}
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(args: Array<String>) {
|
||||
for (index in args.indices) {
|
||||
args[index] = "Hello"
|
||||
}
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(args: Array<String>) {
|
||||
for (index in 0..ar<caret>gs.size - 1) {
|
||||
println(index)
|
||||
}
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(args: Array<String>) {
|
||||
for (index in args.indices) {
|
||||
println(index)
|
||||
}
|
||||
}
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(args: Array<String>) {
|
||||
val ind = 0..<caret>args.size-1
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(args: Array<String>) {
|
||||
val ind = args.indices
|
||||
}
|
||||
idea/testData/inspectionsLocal/replaceManualRangeWithIndicesCallsInspection/simpleExpressionUntil.kt
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(args: Array<String>) {
|
||||
val ind = 0 <caret>until args.size
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(args: Array<String>) {
|
||||
val ind = args.indices
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(args: Array<String>) {
|
||||
for (index in 0..ar<caret>gs.size - 1) {
|
||||
val out = args[index]
|
||||
}
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun test(args: Array<String>) {
|
||||
for (element in args) {
|
||||
val out = element
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user