Open adangel opened 6 years ago
Affects PMD Version: 6.3.0+, 7.0.0
Rule: NullAssignment
Description: If there is a variable declaration without initializer, then the first assignment with null is considered already as a NullAssignment. This should be ignored, since it is the first assignment, which should be allowed by the rule.
Code Sample demonstrating the issue:
String key; if (a) { key = "a"; } else if (b) { key = "b"; } else { key = null; }
See #629 for the original issue.
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]
I think I've found another false-positive for this check (PMD version 6.6.0):
return new Pair<>(found ? a : null, found ? b : null);
I think this also could be considered a bug in PMD, what do you think?
Affects PMD Version: 6.3.0+, 7.0.0
Rule: NullAssignment
Description: If there is a variable declaration without initializer, then the first assignment with null is considered already as a NullAssignment. This should be ignored, since it is the first assignment, which should be allowed by the rule.
Code Sample demonstrating the issue:
See #629 for the original issue.
Running PMD through: [CLI | Ant | Maven | Gradle | Designer | Other]