Added "reportLevel" for determining when a rule violation is reported.

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1384 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Don Leckie
2003-01-28 04:08:24 +00:00
parent bb30b7e839
commit 02a624bc43

View File

@ -128,12 +128,15 @@ public class CyclomaticComplexityRule extends AbstractRule
{
m_entryStack.push(new Entry(node));
super.visit(node, data);
// The {0} "{1}" has a cyclomatic complexity of {2}.
Entry classEntry = (Entry) m_entryStack.pop();
double decisionPoints = (double) classEntry.m_decisionPoints;
double methodCount = (double) classEntry.m_methodCount;
int complexityAverage = (int) (Math.rint(decisionPoints / methodCount));
if ((complexityAverage >= getIntProperty("reportLevel")) ||
(classEntry.m_highestDecisionPoints >= getIntProperty("reportLevel")))
{
// The {0} "{1}" has a cyclomatic complexity of {2}.
RuleContext ruleContext = (RuleContext) data;
String template = getMessage();
String className = node.getImage();
@ -147,6 +150,7 @@ public class CyclomaticComplexityRule extends AbstractRule
int lineNumber = node.getBeginLine();
RuleViolation ruleViolation = createRuleViolation(ruleContext, lineNumber, message);
ruleContext.getReport().addRuleViolation(ruleViolation);
}
return data;
}
@ -199,6 +203,8 @@ public class CyclomaticComplexityRule extends AbstractRule
}
}
if (methodEntry.m_decisionPoints >= getIntProperty("reportLevel"))
{
// The {0} "{1}" has a cyclomatic complexity of {2}.
RuleContext ruleContext = (RuleContext) data;
String template = getMessage();
@ -209,6 +215,7 @@ public class CyclomaticComplexityRule extends AbstractRule
int lineNumber = node.getBeginLine();
RuleViolation ruleViolation = createRuleViolation(ruleContext, lineNumber, message);
ruleContext.getReport().addRuleViolation(ruleViolation);
}
return data;
}