Affects PMD Version:6.41.0
Rule:UseCollectionIsEmpty
Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#usecollectionisempty
Description:
Hi, I found that rule UseCollectionIsEmpty cannot detect list filed from other classes, which is used as list.size()==0. Please refer to the following case:
Code Sample demonstrating the issue:
class Class1 {
public static List<Integer> list1 = new ArrayList<>();
}
class Class2 {
public void foo() {
if(Class1.list1.size() == 0) {} // should report a warning here, but no warning
}
}
Expected outcome:
PMD should report a violation at line 6, but doesn't. This is a false-negative.
Running PMD through: [Maven]
Affects PMD Version:6.41.0
Rule:UseCollectionIsEmpty
Please provide the rule name and a link to the rule documentation:
https://pmd.github.io/latest/pmd_rules_java_bestpractices.html#usecollectionisempty
Description:
Hi, I found that rule UseCollectionIsEmpty cannot detect list filed from other classes, which is used as
list.size()==0. Please refer to the following case:Code Sample demonstrating the issue:
Expected outcome:
PMD should report a violation at line 6, but doesn't. This is a false-negative.
Running PMD through: [Maven]