Files
openide/plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/RemoveForLoopIndices.html
Ilya Kirillov 3386f8f5a9 [kotlin] move inspection descriptions to separate module to reuse in K2
GitOrigin-RevId: e9d7382f4d640e27b1958d1bf2d4c3e639915137
2022-07-13 09:59:31 +00:00

23 lines
679 B
HTML

<html>
<body>
Reports <code>for</code> loops iterating over a collection using the <code>withIndex()</code> function and not using the index variable.
<p>Use the "Remove indices in 'for' loop" quick-fix to clean up the code.</p>
<p><b>Examples:</b></p>
<pre><code>
fun foo(bar: List&lt;String&gt;) {
for ((index : Int, value: String) in bar.withIndex()) { // &lt;== 'index' is unused
println(value)
}
}
</code></pre>
<p>After the quick-fix is applied:</p>
<pre><code>
fun foo(bar: List&lt;String&gt;) {
for (value: String in bar) { // &lt;== '.withIndex()' and 'index' are removed
println(value)
}
}
</code></pre>
</body>
</html>