## com.puppycrawl.tools.checkstyle.checks.metrics
Class AbstractComplexityCheck

    java.lang.Object
      com.puppycrawl.tools.checkstyle.api.AutomaticBean
          com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
              com.puppycrawl.tools.checkstyle.api.Check
                  com.puppycrawl.tools.checkstyle.checks.metrics.AbstractComplexityCheck

All Implemented Interfaces:
  Configurable, Contextualizable

Direct Known Subclasses:
  CyclomaticComplexityCheck, NPathComplexityCheck

    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 BigInteger` `getCurrentValue()`
`int` `getMax()`
`protected abstract String` `getMessageID()`
`int[]` `getRequiredTokens()` The tokens that this check must be registered for.
`protected void` `incrementCurrentValue(BigInteger aBy)` Increments the current value by a specified amount.
`void` `leaveToken(DetailAST aAST)` Called after all the child nodes have been process.
`protected void` `leaveTokenHook(DetailAST aAST)` Hook called when leaving a token.
`protected BigInteger` `popValue()`
`protected void` `pushValue()` Push the current value on the stack
`protected void` `setCurrentValue(BigInteger aValue)` Set the current value
`void` `setMax(int aMax)` Set the maximum threshold allowed.
`void` `visitToken(DetailAST aAST)` Called to process a token.
`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, getTabWidth, getTokenNames, init, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens`

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
`getId, getMessageBundle, getSeverity, getSeverityLevel, 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`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractComplexityCheck

    public AbstractComplexityCheck(int aMax)

  Creates an instance.

  Parameters:
    `aMax` - the threshold of when to report an error

Method Detail

### getMessageID

    protected abstract String getMessageID()

  Returns:
    the message ID to log violations with

### 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

### 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

### getRequiredTokens

    public final int[] getRequiredTokens()

  The tokens that this check must be registered for.

  Overrides:
    `getRequiredTokens` in class `Check`
  Returns:
    the token set this must be registered for.
  See Also:
    `TokenTypes`

### getMax

    public final int getMax()

  Returns:
    the maximum threshold allowed

### setMax

    public final void setMax(int aMax)

  Set the maximum threshold allowed.

  Parameters:
    `aMax` - the maximum threshold

### visitToken

    public void visitToken(DetailAST aAST)

  Called to process a token.

  Overrides:
    `visitToken` in class `Check`
  Parameters:
    `aAST` - the token to process

### leaveToken

    public void leaveToken(DetailAST aAST)

  Called after all the child nodes have been process.

  Overrides:
    `leaveToken` in class `Check`
  Parameters:
    `aAST` - the token leaving

### getCurrentValue

    protected final BigInteger getCurrentValue()

  Returns:
    the current value

### setCurrentValue

    protected final void setCurrentValue(BigInteger aValue)

  Set the current value

  Parameters:
    `aValue` - the new value

### incrementCurrentValue

    protected final void incrementCurrentValue(BigInteger aBy)

  Increments the current value by a specified amount.

  Parameters:
    `aBy` - the amount to increment by

### pushValue

    protected final void pushValue()

  Push the current value on the stack

### popValue

    protected final BigInteger popValue()

  Returns:
    pop a value off the stack and make it the current value

Back to the Checkstyle Home Page