You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
Hi, I found a false negative about the rule UseArrayListInsteadOfVector, please read the first code example below. PMD should have reported a warning in line 5, but it does not. However, in the second code example, PMD can report the warning as expected. Hence, I think this is a false negative. Thank you!
Code Sample demonstrating the issue:
First code example
importorg.Annotation;
@AnnotationpublicclassC {
voidx() {
Vectorv = newVector(); // should report a warning in this line, but no warnings
}
}
Second code example
publicclassC {
voidx() {
Vectorv = newVector(); // Can detect the warning
}
}
Expected outcome:
PMD should report a violation at line 5, but doesn't. This is a false-negative.
Running PMD through:[Maven]
The text was updated successfully, but these errors were encountered:
adangel
changed the title
[java] UseArrayListInsteadOfVector should detect the method with annotation
[java] UseArrayListInsteadOfVector ignores Vector when other classes are imported
Oct 14, 2022
Thanks for the report.
It is not the Annotation, that trips the rule, but the other import, e.g. here we also don't detect Vector:
importsome.OtherClass;
publicclassC {
voidx() {
java.util.Vectorv = newjava.util.Vector(); // Can detect the warning
}
}
Note: your example doesn't really compile, because you didn't import "java.util.Vector". As soon as you add import java.util.Vector; additionally, it works.
adangel
added a commit
to adangel/pmd
that referenced
this issue
Oct 14, 2022
Hi, thanks for your reply. I may ignore the import when submitted the issue, and it seems that problem is not only casuse by the annotation and has been fixed now.
Affects PMD Version:6.47.0
Rule:UseArrayListInsteadOfVector
Please provide the rule name and a link to the rule documentation:
https://pmd.sourceforge.io/pmd-6.50.0/pmd_rules_java_performance.html#usearraylistinsteadofvector
Description:
Hi, I found a false negative about the rule UseArrayListInsteadOfVector, please read the first code example below. PMD should have reported a warning in line 5, but it does not. However, in the second code example, PMD can report the warning as expected. Hence, I think this is a false negative. Thank you!
Code Sample demonstrating the issue:
First code example
Second code example
Expected outcome:
PMD should report a violation at line 5, but doesn't. This is a false-negative.
Running PMD through: [Maven]
The text was updated successfully, but these errors were encountered: