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:
List<Map<String,Object>>
), the rule doesn't seem to trigger even in cases where it shouldboolean ? value : otherValue
), the rule doesn't seem to trigger eitherCode 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.
./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