Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.puppycrawl.tools.checkstyle.checks.metrics
Class CyclomaticComplexityCheck  view CyclomaticComplexityCheck download CyclomaticComplexityCheck.java

java.lang.Object
  extended bycom.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended bycom.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended bycom.puppycrawl.tools.checkstyle.api.Check
              extended bycom.puppycrawl.tools.checkstyle.checks.metrics.AbstractComplexityCheck
                  extended bycom.puppycrawl.tools.checkstyle.checks.metrics.CyclomaticComplexityCheck
All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.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!


Field Summary
private static int DEFAULT_VALUE
          default allowed complexity
 
Fields inherited from class com.puppycrawl.tools.checkstyle.checks.metrics.AbstractComplexityCheck
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.Check
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
 
Constructor Summary
CyclomaticComplexityCheck()
          Create an instance.
 
Method Summary
 int[] getDefaultTokens()
          null
protected  java.lang.String getMessageID()
          null
protected  void visitTokenHook(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          null
 
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.metrics.AbstractComplexityCheck
getCurrentValue, getMax, getRequiredTokens, incrementCurrentValue, leaveToken, leaveTokenHook, popValue, pushValue, setCurrentValue, setMax, visitToken
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, 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, 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
 

Field Detail

DEFAULT_VALUE

private static final int DEFAULT_VALUE
default allowed complexity

See Also:
Constant Field Values
Constructor Detail

CyclomaticComplexityCheck

public CyclomaticComplexityCheck()
Create an instance.

Method Detail

getDefaultTokens

public int[] getDefaultTokens()
null


visitTokenHook

protected final void visitTokenHook(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
null

Overrides:
visitTokenHook in class AbstractComplexityCheck

getMessageID

protected final java.lang.String getMessageID()
null

Specified by:
getMessageID in class AbstractComplexityCheck