Affects PMD Version:
6.30.0
Rule: UnusedAssignment
Property reportUnusedVariables=true
Description:
For-each variable is flagged as unused when used as part of index expression while accessing an array value.
Code Sample demonstrating the issue:
package ds; import static java.lang.System.arraycopy; import static java.util.Arrays.fill; public class RadixSort { private static final int TEN = 10; int[] a; void countSort(int exp) { int[] output = new int[a.length]; int[] count = new int[TEN]; fill(count, 0); for (int val : a) // error flagged here count[(val / exp) % TEN]++; for (int i = 1; i < TEN; i++) count[i] += count[i - 1]; for (int i = a.length - 1; i >= 0; i--) { output[count[(a[i] / exp) % TEN] - 1] = a[i]; count[(a[i] / exp) % TEN]--; } arraycopy(output, 0, a, 0, a.length); } }
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4