1
0
forked from phoedos/pmd

Avoid NPE

This commit is contained in:
Juan Martín Sotuyo Dodero
2018-05-07 02:43:34 -03:00
parent fb55ca703e
commit bcb3f65edb

@ -63,6 +63,10 @@ public class UnnecessaryLocalBeforeReturnRule extends AbstractJavaRule {
.getDeclarations(VariableNameDeclaration.class);
for (Map.Entry<VariableNameDeclaration, List<NameOccurrence>> entry : vars.entrySet()) {
VariableNameDeclaration variableDeclaration = entry.getKey();
if (variableDeclaration.getDeclaratorId().isFormalParameter()) {
continue;
}
List<NameOccurrence> usages = entry.getValue();
if (usages.size() == 1) { // If there is more than 1 usage, then it's not only returned