@Override public Object visit(ASTMethodDeclaration method, Object data) { if (isJUnitMethod(method, data)) { if (!isExpectAnnotated(method.jjtGetParent())) { Map<String, VariableNameDeclaration> variables = getVariables(method); Scope classScope = method.getScope().getParent(); Map<String, List<NameOccurrence>> expectables = getRuleAnnotatedExpectedExceptions(classScope); if (!containsExpectOrAssert(method.getBlock(), expectables, variables)) { addViolation(data, method); } } } return data; }
ASTBlock block = node.getBlock(); if (block == null) { return super.visit(node, data);
@Override public Object visit(final ASTMethodDeclaration method, final Object data) { if (this.isJUnitMethod(method, data) && this.containsPlainJunitAssert(method.getBlock())) { this.addViolation(data, method); } return data; }
@Override public Object visit(final ASTMethodDeclaration method, final Object data) { if (this.isJUnitMethod(method, data) && this.containsPlainJunitAssert(method.getBlock())) { this.addViolation(data, method); } return data; }
private void checkForExtend(ASTClassOrInterfaceDeclaration node, Object data) { /* * The super.toString method should be called in front of the whole implementation * if the current class extends another POJO class * -> this part not checked */ ASTExtendsList extendsList = node.getFirstChildOfType(ASTExtendsList.class); if (extendsList == null) { return; } String baseName = extendsList.getFirstChildOfType(ASTClassOrInterfaceType.class).getImage(); if (!PojoUtils.isPojo(baseName)) { return; } try { // toString() definition ASTMethodDeclaration toStringMethod = (ASTMethodDeclaration)node.findChildNodesWithXPath(XPATH).get(0); ASTBlock block = toStringMethod.getBlock(); if (block.hasDescendantMatchingXPath(TOSTRING_XPATH)) { addViolationWithMessage(data, block, MESSAGE_KEY_PREFIX + ".usesuper"); } } catch (JaxenException e) { throw new RuntimeException("XPath expression " + XPATH + " failed: " + e.getLocalizedMessage(), e); } }
@Override public Object visit(ASTMethodDeclaration method, Object data) { if (isJUnitMethod(method, data)) { if (!isExpectAnnotated(method.jjtGetParent())) { Map<String, VariableNameDeclaration> variables = getVariables(method); Scope classScope = method.getScope().getParent(); Map<String, List<NameOccurrence>> expectables = getRuleAnnotatedExpectedExceptions(classScope); if (!containsExpectOrAssert(method.getBlock(), expectables, variables)) { addViolation(data, method); } } } return data; }
ASTBlock block = node.getBlock(); if (block == null) { return super.visit(node, data);