com.puppycrawl.tools.checkstyle.checks.coding

Class ReturnCountCheck

public final class ReturnCountCheck extends AbstractFormatCheck

Restricts return statements to a specified count (default = 2). Ignores specified methods (equals() by default).

Rationale: Too many return points can be indication that code is attempting to do too much or may be difficult to understand.

Author: Simon Harris TODO: Test for inside a static block

Constructor Summary
ReturnCountCheck()
Creates new instance of the checks.
Method Summary
voidbeginTree(DetailAST aRootAST)
{@inheritDoc}
int[]getDefaultTokens()
{@inheritDoc}
intgetMax()
Getter for max property.
int[]getRequiredTokens()
{@inheritDoc}
voidleaveToken(DetailAST aAST)
{@inheritDoc}
voidsetMax(int aMax)
Setter for max property.
voidvisitToken(DetailAST aAST)
{@inheritDoc}

Constructor Detail

ReturnCountCheck

public ReturnCountCheck()
Creates new instance of the checks.

Method Detail

beginTree

public void beginTree(DetailAST aRootAST)
{@inheritDoc}

getDefaultTokens

public int[] getDefaultTokens()
{@inheritDoc}

getMax

public int getMax()
Getter for max property.

Returns: maximum allowed number of return statements.

getRequiredTokens

public int[] getRequiredTokens()
{@inheritDoc}

leaveToken

public void leaveToken(DetailAST aAST)
{@inheritDoc}

setMax

public void setMax(int aMax)
Setter for max property.

Parameters: aMax maximum allowed number of return statements.

visitToken

public void visitToken(DetailAST aAST)
{@inheritDoc}