pmd-5.0.0: ImmutableField false positive on self-inc/dec
A source code analyzer
Brought to you by:
adangel,
juansotuyo
Hi, I'm seeing PDM 5.0.0 reporting the following:
pmd_inc.java:2 Private field 'test' could be made final; it is only initialized in the declaration or constructor.
about the following test case:
public class pmd_inc {
private int test;
public pmd_inc() { this.test = 2; } public int get_test() { return this.test; } public void inc_test(int val) { this.test += val; }
}
It seems as if PMD doesn't recognize that "test" is in fact mutable through the += operator and wrongly suggest marking it as final.
Thank you for the bug report. It will be fixed for PMD 5.1.