From 1946ab84391a3776d1ab53c48c9f6559b58c3e7d Mon Sep 17 00:00:00 2001 From: Don Leckie Date: Fri, 7 Feb 2003 21:55:15 +0000 Subject: [PATCH] Fixed problem where constructors were not testing the reporting level. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1409 51baf565-9d33-0410-a72c-fc3788e3496d --- .../pmd/rules/CyclomaticComplexityRule.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pmd/src/net/sourceforge/pmd/rules/CyclomaticComplexityRule.java b/pmd/src/net/sourceforge/pmd/rules/CyclomaticComplexityRule.java index adbf4b3fb9..6d2785d6c8 100644 --- a/pmd/src/net/sourceforge/pmd/rules/CyclomaticComplexityRule.java +++ b/pmd/src/net/sourceforge/pmd/rules/CyclomaticComplexityRule.java @@ -243,16 +243,19 @@ public class CyclomaticComplexityRule extends AbstractRule classEntry.m_highestDecisionPoints = constructorDecisionPointCount; } - // The {0} "{1}" has a cyclomatic complexity of {2}. - RuleContext ruleContext = (RuleContext) data; - String template = getMessage(); - String constructorName = classEntry.m_node.getImage(); - String complexity = String.valueOf(constructorDecisionPointCount); - String[] args = {"constructor", constructorName, complexity}; - String message = MessageFormat.format(template, args); - int lineNumber = node.getBeginLine(); - RuleViolation ruleViolation = createRuleViolation(ruleContext, lineNumber, message); - ruleContext.getReport().addRuleViolation(ruleViolation); + if (constructorEntry.m_decisionPoints >= getIntProperty("reportLevel")) + { + // The {0} "{1}" has a cyclomatic complexity of {2}. + RuleContext ruleContext = (RuleContext) data; + String template = getMessage(); + String constructorName = classEntry.m_node.getImage(); + String complexity = String.valueOf(constructorDecisionPointCount); + String[] args = {"constructor", constructorName, complexity}; + String message = MessageFormat.format(template, args); + int lineNumber = node.getBeginLine(); + RuleViolation ruleViolation = createRuleViolation(ruleContext, lineNumber, message); + ruleContext.getReport().addRuleViolation(ruleViolation); + } return data; }