A RetroSearch Logo

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

Search Query:

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

[java] AvoidInstantiatingObjectsInLoops: False positive - should not flag objects when assigned to lists/arrays · Issue #2207 · pmd/pmd · GitHub

Affects PMD Version:
6.20.0
Rule:
AvoidInstantiatingObjectsInLoops
Description:
https://stackoverflow.com/questions/17340421/pmd-avoid-instantiating-new-objects-inside-loops
Code Sample demonstrating the issue
From StackOverflow post:

import java.awt.Dimension;

public class PMDDemo {
    public static void main(final String[] args) {
        final Dimension[] arr = new Dimension[10];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = new Dimension(i, i); // rule violation here
        }
    }
}

Similarly, if object created is added to a list or collection object.

Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]

Similar issues:


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