A RetroSearch Logo

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

Search Query:

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

[java] UseDiamondOperator false negatives · Issue #2545 · pmd/pmd · GitHub

Affects PMD Version: 6.23.0 and 6.24.0 (but not 6.22.0)

Make sure, to test with the latest PMD version.

Description:

I've identified a couple of (what I believe are) false negatives for rule UseDiamondOperator. These seem to have been introduced in PMD 6.23.0, probably as a side effect of fixing #1723.

These false negatives are as follows:

Code Sample demonstrating the issue:

import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
public class File {
  List<Map<String,Object>> l = new ArrayList<Map<String,Object>>(); // FN
  public void test() {
    final List<String> l2;
    l2 = true ? new ArrayList<String>() : new ArrayList<String>(); // FN
  }
  static {
    l = new ArrayList<Map<String,Object>>(); // FN
  }
}

PMD 6.22.0 reports the following:

/tmp/File.java:6: Explicit type arguments can be replaced by Diamond Operator
/tmp/File.java:9: Explicit type arguments can be replaced by Diamond Operator
/tmp/File.java:9: Explicit type arguments can be replaced by Diamond Operator
/tmp/File.java:12: Explicit type arguments can be replaced by Diamond Operator

PMD 6.23.0 and 6.24.0 report no violations at all.

Steps to reproduce:

Please provide detailed steps for how we can reproduce the bug.

  1. Save the code example above to /tmp/File.java
  2. Run ./run.sh pmd -d /tmp/File.java -R category/java/codestyle.xml/UseDiamondOperator

Running PMD through: CLI


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