Rule Set:rulesets/java/sunsecure.xml/ArrayIsStoredDirectly
Description:
False positive for ArrayIsStoredDirectly
when defensively copying an array (manually) and using the this
keyword to refer to the instance variable.
Code Sample demonstrating the issue:
public class Foo {
private final int[] a;
public Foo(int[] b) {
this.a = new int[b.length];
for (int i = 0; i < b.length; i++) {
this.a[i] = b[i]; // triggers ArrayIsStoredDirectly
a[i] = b[i]; // no warning
this.a[i] = b[i]; // triggers ArrayIsStoredDirectly
}
}
}
Running PMD through: CLI
pmd-bin-5.7.0/bin/run.sh pmd -d . -rulesets java-sunsecure
Foo.java:4: The user-supplied array 'b' is stored directly.
Foo.java:4: The user-supplied array 'b' is stored directly.
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