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
This commit is contained in:
Don Leckie
2003-02-07 21:55:15 +00:00
parent dd82e9730e
commit 1946ab8439

View File

@ -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;
}