mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
23 lines
679 B
HTML
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<String>) {
|
|
for ((index : Int, value: String) in bar.withIndex()) { // <== 'index' is unused
|
|
println(value)
|
|
}
|
|
}
|
|
</code></pre>
|
|
<p>After the quick-fix is applied:</p>
|
|
<pre><code>
|
|
fun foo(bar: List<String>) {
|
|
for (value: String in bar) { // <== '.withIndex()' and 'index' are removed
|
|
println(value)
|
|
}
|
|
}
|
|
</code></pre>
|
|
</body>
|
|
</html>
|