com.puppycrawl.tools.checkstyle.checks.metrics

Class AbstractComplexityCheck

public abstract class AbstractComplexityCheck extends Check

Base class for checks the calculate complexity based around methods.

Author: Simon Harris Oliver Burn

Constructor Summary
AbstractComplexityCheck(int aMax)
Creates an instance.
Method Summary
protected intgetCurrentValue()
intgetMax()
protected abstract StringgetMessageID()
int[]getRequiredTokens()
{@inheritDoc}
protected voidincrementCurrentValue(int aBy)
Increments the current value by a specified amount.
voidleaveToken(DetailAST aAST)
{@inheritDoc}
protected voidleaveTokenHook(DetailAST aAST)
Hook called when leaving a token.
protected intpopValue()
protected voidpushValue()
Push the current value on the stack
protected voidsetCurrentValue(int aValue)
Set the current value
voidsetMax(int aMax)
Set the maximum threshold allowed.
voidvisitToken(DetailAST aAST)
{@inheritDoc}
protected voidvisitTokenHook(DetailAST aAST)
Hook called when visiting a token.

Constructor Detail

AbstractComplexityCheck

public AbstractComplexityCheck(int aMax)
Creates an instance.

Parameters: aMax the threshold of when to report an error

Method Detail

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()
{@inheritDoc}

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)
{@inheritDoc}

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)
{@inheritDoc}

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