A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/4091 below:

[java] AvoidArrayLoops false negative with do-while loops · Issue #4091 · pmd/pmd · GitHub

Affects PMD Version:6.47.0

Rule:AvoidArrayLoops

Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/latest/pmd_rules_java_performance.html#avoidarrayloops

Description:
Hi, I found an inconsistent bug about the rule AvoidArrayLoops, please read the code example below. PMD reports a warning in line 10, but no warning in line 6. However, these two statements are equivalent. Hence, I think this is an inconsistent outcome. The root cause is the xpath pattern in Link doesn't consider DoStatement. Thanks.

Code Sample demonstrating the issue:

public void foo() {
    int[] a = new int[10];
    int[] b = new int[10];
    final int c = 6;
    do {
        b[i] = a[i+6];  // no warning
        i++;
    } while(i < 6);
    while(i < 6) {
        b[i] = a[i + 6];  // report a warning
        i++;
    }
}

Running PMD through: [Maven]


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