com.puppycrawl.tools.checkstyle.checks.coding

Class MissingSwitchDefaultCheck

Implemented Interfaces:
Configurable, Contextualizable

public class MissingSwitchDefaultCheck
extends DescendantTokenCheck

Checks that switch statement has "default" clause.

Rationale: It's usually a good idea to introduce a default case in every switch statement. Even if the developer is sure that all currently possible cases are covered, this should be expressed in the default branch, e.g. by using an assertion. This way the code is protected aginst later changes, e.g. introduction of new types in an enumeration type.

An example of how to configure the check is:

 <module name="MissingSwitchDefault"/>
 

Author:
o_sukhodolsky

Constructor Summary

MissingSwitchDefaultCheck()
Creates new instance of the check.

Method Summary

int[]
getAcceptableTokens()
int[]
getDefaultTokens()

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

getAcceptableTokens, getDefaultTokens, setLimitedTokens, setMaximumDepth, setMaximumMessage, setMaximumNumber, setMinimumDepth, setMinimumMessage, setMinimumNumber, visitToken

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

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

Constructor Details

MissingSwitchDefaultCheck

public MissingSwitchDefaultCheck()
Creates new instance of the check.

Method Details

getAcceptableTokens

public int[] getAcceptableTokens()
Overrides:
getAcceptableTokens in interface DescendantTokenCheck

See Also:
Check


getDefaultTokens

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

See Also:
Check