Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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 int` | `getCurrentValue()`
`int` | `getMax()`
`protected abstract java.lang.String` | `getMessageID()`
`int[]` | `getRequiredTokens()` The tokens that this check must be registered for.
`protected void` | `incrementCurrentValue(int 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 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)` 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
`getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, log, log, log, 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 java.lang.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 int getCurrentValue()

  Returns:
    the current value

### setCurrentValue

    protected final void setCurrentValue(int aValue)

  Set the current value

  Parameters:
    `aValue` - the new value

### incrementCurrentValue

    protected final void incrementCurrentValue(int 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 int popValue()

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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Back to the Checkstyle Home Page
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD