use of net.sourceforge.pmd.lang.ecmascript.ast.ASTReturnStatement in project pmd by pmd.
the class ConsistentReturnRule method visit.
@Override
public Object visit(ASTFunctionNode functionNode, Object data) {
List<ASTReturnStatement> returnStatements = functionNode.findDescendantsOfType(ASTReturnStatement.class);
Boolean hasResult = null;
for (ASTReturnStatement returnStatement : returnStatements) {
// Return for this function?
if (functionNode == returnStatement.getFirstParentOfType(ASTFunctionNode.class)) {
if (hasResult == null) {
hasResult = Boolean.valueOf(returnStatement.hasResult());
} else {
// Return has different result from previous return?
if (hasResult.booleanValue() != returnStatement.hasResult()) {
addViolation(data, functionNode);
break;
}
}
}
}
return data;
}
Aggregations