Fixed divide by zero bug that would cause a large class complexity number.

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1404 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Don Leckie
2003-02-06 17:35:26 +00:00
parent 1baf96f8e7
commit 5a58619686

View File

@ -131,7 +131,7 @@ public class CyclomaticComplexityRule extends AbstractRule
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));
int complexityAverage = (methodCount == 0) ? 1 : (int) (Math.rint(decisionPoints / methodCount));
if ((complexityAverage >= getIntProperty("reportLevel")) ||
(classEntry.m_highestDecisionPoints >= getIntProperty("reportLevel")))