com.puppycrawl.tools.checkstyle.checks.blocks

Class EmptyBlockCheck

Implemented Interfaces:
Configurable, Contextualizable

public class EmptyBlockCheck
extends AbstractOptionCheck

Checks for empty blocks. The policy to verify is specified using the BlockOption class and defaults to BlockOption.STMT.

By default the check will check the following blocks: LITERAL_WHILE, LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_DO, LITERAL_IF, LITERAL_ELSE, LITERAL_FOR, STATIC_INIT.

An example of how to configure the check is:

 <module name="EmptyBlock"/>
 

An example of how to configure the check for the BlockOption.TEXT policy and only catch blocks is:

 <module name="EmptyBlock">
    <property name="tokens" value="LITERAL_CATCH"/>
    <property name="option" value="text"/>
 </module>
 
Author:
Lars K?hne

Constructor Summary

EmptyBlockCheck()
Creates a new EmptyBlockCheck instance.

Method Summary

int[]
getDefaultTokens()
void
visitToken(DetailAST aAST)

Methods inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck

getAbstractOption, setOption

Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check

beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getDefaultTokens, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens, visitToken

Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter

getId, getMessageBundle, getSeverity, getSeverityLevel, log, log, 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

Constructor Details

EmptyBlockCheck

public EmptyBlockCheck()
Creates a new EmptyBlockCheck instance.

Method Details

getDefaultTokens

public int[] getDefaultTokens()
Overrides:
getDefaultTokens in interface Check

visitToken

public void visitToken(DetailAST aAST)
Overrides:
visitToken in interface Check