com.puppycrawl.tools.checkstyle.checks.metrics

Class AbstractComplexityCheck

Implemented Interfaces:
Configurable, Contextualizable
Known Direct Subclasses:
CyclomaticComplexityCheck, NPathComplexityCheck

public abstract class AbstractComplexityCheck
extends Check

Base class for checks the calculate complexity based around methods.
Authors:
Simon Harris
Oliver Burn

Constructor Summary

AbstractComplexityCheck(int aMax)
Creates an instance.

Method Summary

protected int
getCurrentValue()
int
getMax()
protected abstract String
getMessageID()
int[]
getRequiredTokens()
protected void
incrementCurrentValue(int aBy)
Increments the current value by a specified amount.
void
leaveToken(DetailAST aAST)
protected void
leaveTokenHook(DetailAST aAST)
Hook called when leaving a token.
protected int
popValue()
protected void
pushValue()
Push the current value on the stack
protected void
setCurrentValue(int aValue)
Set the current value
void
setMax(int aMax)
Set the maximum threshold allowed.
void
visitToken(DetailAST aAST)
protected void
visitTokenHook(DetailAST aAST)
Hook called when visiting a token.

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

AbstractComplexityCheck

public AbstractComplexityCheck(int aMax)
Creates an instance.
Parameters:
aMax - the threshold of when to report an error

Method Details

getCurrentValue

protected final int getCurrentValue()
Returns:
the current value

getMax

public final int getMax()
Returns:
the maximum threshold allowed

getMessageID

protected abstract String getMessageID()
Returns:
the message ID to log violations with

getRequiredTokens

public final int[] getRequiredTokens()
Overrides:
getRequiredTokens in interface Check

incrementCurrentValue

protected final void incrementCurrentValue(int aBy)
Increments the current value by a specified amount.
Parameters:
aBy - the amount to increment by

leaveToken

public void leaveToken(DetailAST aAST)
Overrides:
leaveToken in interface Check

leaveTokenHook

protected void leaveTokenHook(DetailAST aAST)
Hook called when leaving a token. Will not be called the method definition tokens.
Parameters:
aAST - the token being left

popValue

protected final int popValue()
Returns:
pop a value off the stack and make it the current value

pushValue

protected final void pushValue()
Push the current value on the stack

setCurrentValue

protected final void setCurrentValue(int aValue)
Set the current value
Parameters:
aValue - the new value

setMax

public final void setMax(int aMax)
Set the maximum threshold allowed.
Parameters:
aMax - the maximum threshold

visitToken

public void visitToken(DetailAST aAST)
Overrides:
visitToken in interface Check

visitTokenHook

protected void visitTokenHook(DetailAST aAST)
Hook called when visiting a token. Will not be called the method definition tokens.
Parameters:
aAST - the token being visited