@Override public Object visit(ASTAnnotation node, Object data) { final List<ASTMemberValuePair> annotationProperties = node.findDescendantsOfType(ASTMemberValuePair.class); // all that needs to be done is check to if there's a single property in the annotation and if if that property is value // then it's a violation and it should be resolved. if (annotationProperties.size() == 1 && "value".equals(annotationProperties.get(0).getImage())) { addViolation(data, node); } return data; } }
private boolean isOkUsingLombok(ASTClassOrInterfaceDeclaration parent) { // check if there's a lombok no arg private constructor, if so skip the rest of the rules ASTAnnotation annotation = parent.getAnnotation("lombok.NoArgsConstructor"); if (annotation != null) { List<ASTMemberValuePair> memberValuePairs = annotation.findDescendantsOfType(ASTMemberValuePair.class); for (ASTMemberValuePair memberValuePair : memberValuePairs) { // to set the access level of a constructor in lombok, you set the access property on the annotation if ("access".equals(memberValuePair.getImage())) { List<ASTName> names = memberValuePair.findDescendantsOfType(ASTName.class); for (ASTName name : names) { // check to see if the value of the member value pair ends PRIVATE. This is from the AccessLevel enum in Lombok if (name.getImage().endsWith("PRIVATE")) { // if the constructor is found and the accesslevel is private no need to check anything else return true; } } } } } return false; }
for (ASTLiteral element : findDescendantsOfType(ASTLiteral.class)) { if (element.hasImageEqualTo("\"PMD\"") || element.hasImageEqualTo("\"PMD." + rule.getName() + "\"")
@Override public Object visit(ASTAnnotation node, Object data) { final List<ASTMemberValuePair> annotationProperties = node.findDescendantsOfType(ASTMemberValuePair.class); // all that needs to be done is check to if there's a single property in the annotation and if if that property is value // then it's a violation and it should be resolved. if (annotationProperties.size() == 1 && "value".equals(annotationProperties.get(0).getImage())) { addViolation(data, node); } return data; } }
private boolean isOkUsingLombok(ASTClassOrInterfaceDeclaration parent) { // check if there's a lombok no arg private constructor, if so skip the rest of the rules ASTAnnotation annotation = parent.getAnnotation("lombok.NoArgsConstructor"); if (annotation != null) { List<ASTMemberValuePair> memberValuePairs = annotation.findDescendantsOfType(ASTMemberValuePair.class); for (ASTMemberValuePair memberValuePair : memberValuePairs) { // to set the access level of a constructor in lombok, you set the access property on the annotation if ("access".equals(memberValuePair.getImage())) { List<ASTName> names = memberValuePair.findDescendantsOfType(ASTName.class); for (ASTName name : names) { // check to see if the value of the member value pair ends PRIVATE. This is from the AccessLevel enum in Lombok if (name.getImage().endsWith("PRIVATE")) { // if the constructor is found and the accesslevel is private no need to check anything else return true; } } } } } return false; }
for (ASTLiteral element : findDescendantsOfType(ASTLiteral.class)) { if (element.hasImageEqualTo("\"PMD\"") || element.hasImageEqualTo("\"PMD." + rule.getName() + "\"")
return super.visit(node, data); List<ASTMemberValuePair> memberValuePairList = node.findDescendantsOfType(ASTMemberValuePair.class); if (shouldSkip(memberValuePairList)) { return super.visit(node, data);