com.puppycrawl.tools.checkstyle.checks.metrics

Class CyclomaticComplexityCheck

Implemented Interfaces:
Configurable, Contextualizable

public class CyclomaticComplexityCheck
extends AbstractComplexityCheck

Checks cyclomatic complexity against a specified limit. The complexity is measured by the number of "if", "while", "do", "for", "?:", "catch", "switch", "case", "&&" and "||" statements (plus one) in the body of the member. It is a measure of the minimum number of possible paths through the source and therefore the number of required tests. Generally 1-4 is considered good, 5-7 ok, 8-10 consider re-factoring, and 11+ re-factor now!
Authors:
Simon Harris
Oliver Burn

Constructor Summary

CyclomaticComplexityCheck()
Create an instance.

Method Summary

int[]
getDefaultTokens()
protected String
getMessageID()
protected void
visitTokenHook(DetailAST aAST)

Methods inherited from class com.puppycrawl.tools.checkstyle.checks.metrics.AbstractComplexityCheck

getCurrentValue, getMax, getMessageID, getRequiredTokens, incrementCurrentValue, leaveToken, leaveTokenHook, popValue, pushValue, setCurrentValue, setMax, visitToken, visitTokenHook

Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check

beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getDefaultTokens, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens, visitToken

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter

getId, getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, log, log, log, setId, setSeverity

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean

configure, contextualize, finishLocalSetup, getConfiguration, setupChild

Constructor Details

CyclomaticComplexityCheck

public CyclomaticComplexityCheck()
Create an instance.

Method Details

getDefaultTokens

public int[] getDefaultTokens()
Overrides:
getDefaultTokens in interface Check

getMessageID

protected final String getMessageID()
Overrides:
getMessageID in interface AbstractComplexityCheck

visitTokenHook

protected final void visitTokenHook(DetailAST aAST)
Overrides:
visitTokenHook in interface AbstractComplexityCheck