A RetroSearch Logo

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

Search Query:

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

[java] AvoidArrayLoops should consider final variables · Issue #3847 · pmd/pmd · GitHub

Affects PMD Version:6.42.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 a false negative about the rule AvoidArrayLoops. Please read the following case. PMD should have reported a warning at line 6, but it doesn't. However, it can detect line 7. I think line 6 and line 7 are same. Hence, this is a false negative. Thanks for your consideration.

Code Sample demonstrating the issue:

public void sample() {
    int[] a = new int[10];
    int[] b = new int[10];
    final int c = 6;
    for (int i=0;i<10;i++) {
        b[i]=a[i+c];  // should report a warning at this line
        // b[i]=a[i+6];  // This line can be detected
    }
}

Expected outcome: A warning

PMD should report a violation at line 6, but doesn't. This is a false-negative.

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