From 708957b7eee4b2cdfd748f29782018df99b0da0a Mon Sep 17 00:00:00 2001 From: Don Leckie Date: Sun, 26 Jan 2003 21:34:29 +0000 Subject: [PATCH] Fixed NullPointerException for interfaces. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1374 51baf565-9d33-0410-a72c-fc3788e3496d --- .../pmd/rules/CyclomaticComplexityRule.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pmd/src/net/sourceforge/pmd/rules/CyclomaticComplexityRule.java b/pmd/src/net/sourceforge/pmd/rules/CyclomaticComplexityRule.java index 9d58beaf47..fc970b6e09 100644 --- a/pmd/src/net/sourceforge/pmd/rules/CyclomaticComplexityRule.java +++ b/pmd/src/net/sourceforge/pmd/rules/CyclomaticComplexityRule.java @@ -6,6 +6,7 @@ import net.sourceforge.pmd.RuleViolation; import net.sourceforge.pmd.ast.ASTConstructorDeclaration; import net.sourceforge.pmd.ast.ASTForStatement; import net.sourceforge.pmd.ast.ASTIfStatement; +import net.sourceforge.pmd.ast.ASTInterfaceDeclaration; import net.sourceforge.pmd.ast.ASTMethodDeclaration; import net.sourceforge.pmd.ast.ASTMethodDeclarator; import net.sourceforge.pmd.ast.ASTSwitchLabel; @@ -143,6 +144,18 @@ public class CyclomaticComplexityRule extends AbstractRule */ public Object visit(ASTMethodDeclaration node, Object data) { + Node parentNode = node.jjtGetParent(); + + while (parentNode != null) + { + if (parentNode instanceof ASTInterfaceDeclaration) + { + return data; + } + + parentNode = parentNode.jjtGetParent(); + } + m_entryStack.push(new Entry(node)); super.visit(node, data); Entry methodEntry = (Entry) m_entryStack.pop();