mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Apply Kotlin inspection "Range can be converted to indices or iteration"
GitOrigin-RevId: 2055bae4ddb461c2d4ae938be6e809dd3b8097eb
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9bcd5a0415
commit
98ba892cc5
+1
-1
@@ -118,7 +118,7 @@ class Main {
|
||||
TestCase.assertTrue("Is method", member is PsiMethod)
|
||||
val parameters = (member as PsiMethod).parameterList.parameters
|
||||
TestCase.assertEquals("Parameter count", expectedParameterTypes.size, parameters.size)
|
||||
for (i in 0 until expectedParameterTypes.size) {
|
||||
for (i in expectedParameterTypes.indices) {
|
||||
TestCase.assertEquals("Parameter $i", expectedParameterTypes[i], parameters[i].type.canonicalText)
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -48,7 +48,7 @@ class DataFrameCSVAdapter {
|
||||
val columnsInfo = ArrayList<ColumnInfo>()
|
||||
|
||||
var previous = 0
|
||||
for (i in 0 until data.length) {
|
||||
for (i in data.indices) {
|
||||
if (data[i] != '\n' && data[i] != '\t') {
|
||||
continue
|
||||
}
|
||||
@@ -112,8 +112,8 @@ class DataFrameCSVAdapter {
|
||||
|
||||
val columns = ArrayList<ArrayList<*>>(columnsInfo.size)
|
||||
|
||||
for (i in 0 until columnsInfo.size) {
|
||||
columns.add(columnsInfo[i].type!!.createDataArray())
|
||||
for (info in columnsInfo) {
|
||||
columns.add(info.type!!.createDataArray())
|
||||
}
|
||||
|
||||
// Skip first line (header).
|
||||
@@ -144,7 +144,7 @@ class DataFrameCSVAdapter {
|
||||
}
|
||||
|
||||
val realColumns = ArrayList<Column<*>>(columnsInfo.size)
|
||||
for (i in 0 until columnsInfo.size) {
|
||||
for (i in columnsInfo.indices) {
|
||||
realColumns.add(columnsInfo[i].type!!.createDataColumn(columnsInfo[i].name, columns[i]))
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -43,19 +43,19 @@ class DataFrameImpl(private val columns: ArrayList<Column<*>>) : DataFrame() {
|
||||
is IntType -> {
|
||||
val intColumn = columns[i] as IntColumn
|
||||
val data = ArrayList<Int>(intColumn.size)
|
||||
(0 until sortedIndices.size).forEach { data.add(intColumn[sortedIndices[it]]) }
|
||||
sortedIndices.forEach { data.add(intColumn[it]) }
|
||||
columns[i] = IntColumn(columns[i].name, data)
|
||||
}
|
||||
is DoubleType -> {
|
||||
val doubleColumn = columns[i] as DoubleColumn
|
||||
val data = ArrayList<Double>(doubleColumn.size)
|
||||
(0 until sortedIndices.size).forEach { data.add(doubleColumn[sortedIndices[it]]) }
|
||||
sortedIndices.forEach { data.add(doubleColumn[it]) }
|
||||
columns[i] = DoubleColumn(columns[i].name, data)
|
||||
}
|
||||
is StringType -> {
|
||||
val stringColumn = columns[i] as StringColumn
|
||||
val data = ArrayList<String?>(stringColumn.size)
|
||||
(0 until sortedIndices.size).forEach { data.add(stringColumn[sortedIndices[it]]) }
|
||||
sortedIndices.forEach { data.add(stringColumn[it]) }
|
||||
columns[i] = StringColumn(columns[i].name, data)
|
||||
}
|
||||
else -> throw Exception("Unsupported column type ${columns[i].type} in sorting.")
|
||||
|
||||
@@ -280,7 +280,7 @@ abstract class DiffTestCase : TestCase() {
|
||||
val lines1 = matching.split('_', '*')
|
||||
val lines2 = text.split('\n')
|
||||
assertEquals(lines1.size, lines2.size)
|
||||
for (i in 0..lines1.size - 1) {
|
||||
for (i in lines1.indices) {
|
||||
assertEquals(lines1[i].length, lines2[i].length, "line $i")
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -668,7 +668,7 @@ class ComparisonUtilAutoTest : HeavyDiffTestCase() {
|
||||
}
|
||||
|
||||
private fun countNonWhitespaceCharacters(line: CharSequence): Int {
|
||||
return (0 until line.length).count { !StringUtil.isWhiteSpace(line[it]) }
|
||||
return line.indices.count { !StringUtil.isWhiteSpace(line[it]) }
|
||||
}
|
||||
|
||||
private fun getFirstLastLines(text: Document, start: Int, end: Int): Couple<CharSequence>? {
|
||||
|
||||
@@ -47,7 +47,7 @@ class DiffUtilTest : DiffTestCase() {
|
||||
|
||||
val sortedIndexes = DiffUtil.getSortedIndexes(list, comparator)
|
||||
val expected = ContainerUtil.sorted(list, comparator)
|
||||
val actual = (0..values.size - 1).map { values[sortedIndexes[it]] }
|
||||
val actual = values.indices.map { values[sortedIndexes[it]] }
|
||||
|
||||
assertOrderedEquals(expected, actual)
|
||||
assertEquals(sortedIndexes.toSet().size, list.size)
|
||||
|
||||
+2
-2
@@ -80,8 +80,8 @@ class CollectThreadInfoVisitor(private val threadsMap: Long2ObjectMap<ThreadInfo
|
||||
|
||||
override fun visitStackTrace(stackTraceSerialNumber: Long, threadSerialNumber: Long, numberOfFrames: Int, stackFrameIds: LongArray) {
|
||||
val frames = ArrayList<String>(stackFrameIds.size)
|
||||
for (i in 0 until stackFrameIds.size) {
|
||||
frames.add(stackFrameIdToStringMap[stackFrameIds[i]])
|
||||
for (id in stackFrameIds) {
|
||||
frames.add(stackFrameIdToStringMap[id])
|
||||
}
|
||||
threadsMap.put(threadSerialNumber, ThreadInfo(frames))
|
||||
}
|
||||
|
||||
@@ -754,8 +754,7 @@ object Switcher : BaseSwitcherAction(null) {
|
||||
private fun addSmartShortcut(window: SwitcherToolWindow, keymap: MutableMap<String?, SwitcherToolWindow?>): Boolean {
|
||||
val title = window.mainText
|
||||
if (StringUtil.isEmpty(title)) return false
|
||||
for (i in 0 until title.length) {
|
||||
val c = title[i]
|
||||
for (c in title) {
|
||||
if (Character.isUpperCase(c) && addShortcut(keymap, window, c.toString())) {
|
||||
return true
|
||||
}
|
||||
|
||||
+1
-1
@@ -614,7 +614,7 @@ class FeatureUsageEventLoggerTest : HeavyPlatformTestCase() {
|
||||
|
||||
val actual = logger.testWriter.logged
|
||||
assertEquals(expected.size, actual.size)
|
||||
for (i in 0 until expected.size) {
|
||||
for (i in expected.indices) {
|
||||
assertEvent(actual[i], expected[i])
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -445,7 +445,7 @@ my_list^ =^ [^"^one^"^,^ "^two^"^,^ "^three^"^,^
|
||||
|
||||
private fun CharSequence.offsets(direction: Direction): IntProgression =
|
||||
when (direction) {
|
||||
FORWARD -> 0 until length
|
||||
FORWARD -> indices
|
||||
BACKWARD -> length downTo 1
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ internal class InputClassScope(generator: DomainGenerator, namePath: NamePath) :
|
||||
override val typeDirection = TypeData.Direction.INPUT
|
||||
|
||||
fun generateDeclarationBody(out: TextOutput, list: List<ItemDescriptor.Named>) {
|
||||
for (i in 0 until list.size) {
|
||||
for (i in list.indices) {
|
||||
val named = list[i]
|
||||
if (named.description != null) {
|
||||
out.doc(named.description)
|
||||
|
||||
@@ -6,7 +6,7 @@ internal fun appendMethodSignatureJava(method: Method, paramNames: List<String>,
|
||||
out.append(method.name).append('(')
|
||||
var firstArg = true
|
||||
val types = method.genericParameterTypes
|
||||
for (i in 0..types.size - 1) {
|
||||
for (i in types.indices) {
|
||||
val arg = types[i]
|
||||
if (firstArg) {
|
||||
firstArg = false
|
||||
|
||||
@@ -122,7 +122,7 @@ abstract class PathEditBase(final override val path: ByteArray) : PathEdit
|
||||
private fun encodePath(path: String): ByteArray {
|
||||
val bytes = Charsets.UTF_8.encode(path).toByteArray()
|
||||
if (SystemInfo.isWindows) {
|
||||
for (i in 0 until bytes.size) {
|
||||
for (i in bytes.indices) {
|
||||
if (bytes[i].toChar() == '\\') {
|
||||
bytes[i] = '/'.toByte()
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ abstract class YAMLBlockScalarImpl(node: ASTNode) : YAMLScalarImpl(node) {
|
||||
if (includeFirstLineInContent) return IMPLICIT_INDENT
|
||||
val headerNode = getNthContentTypeChild(0) ?: return IMPLICIT_INDENT
|
||||
val header = headerNode.text
|
||||
for (i in 0 until header.length) {
|
||||
for (i in header.indices) {
|
||||
if (Character.isDigit(header[i])) {
|
||||
val k = i + 1
|
||||
// YAML 1.2 standard does not allow more then 1 symbol in indentation number
|
||||
|
||||
Reference in New Issue
Block a user