com.puppycrawl.tools.checkstyle.checks.coding

Class RedundantThrowsCheck

Implemented Interfaces:
Configurable, Contextualizable

public class RedundantThrowsCheck
extends AbstractTypeAwareCheck

Checks for redundant exceptions declared in throws clause such as duplicates, unchecked exceptions or subclasses of another declared exception.

An example of how to configure the check is:

 <module name="RedundantThrows">
    <property name="allowUnchecked" value="true"/>
    <property name="allowSubclasses" value="true"/>
 </module>
 

Author:
o_sukhodolsky

Nested Class Summary

Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractTypeAwareCheck

AbstractTypeAwareCheck.ClassInfo

Constructor Summary

RedundantThrowsCheck()
Create an object.

Method Summary

int[]
getDefaultTokens()
protected void
logLoadError(FullIdent aIdent)
Logs error if unable to load class information.
protected void
processAST(DetailAST aAST)
Checks exceptions declared in throws for a method or constructor.
void
setAllowSubclasses(boolean aAllowSubclasses)
Getter for allowSubclasses property.
void
setAllowUnchecked(boolean aAllowUnchecked)
Getter for allowUnchecked property.

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

beginTree, getCurrentClassName, isSameType, isShortName, isSubclass, isUnchecked, leaveToken, logLoadError, processAST, resolveClass, tryLoadClass, 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

RedundantThrowsCheck

public RedundantThrowsCheck()
Create an object.

Method Details

getDefaultTokens

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

See Also:
Check


logLoadError

protected final void logLoadError(FullIdent aIdent)
Logs error if unable to load class information.
Overrides:
logLoadError in interface AbstractTypeAwareCheck

Parameters:
aIdent - class name for which we can no load class.


processAST

protected final void processAST(DetailAST aAST)
Checks exceptions declared in throws for a method or constructor.
Overrides:
processAST in interface AbstractTypeAwareCheck

Parameters:
aAST - the tree node for the method or constructor.


setAllowSubclasses

public void setAllowSubclasses(boolean aAllowSubclasses)
Getter for allowSubclasses property.

Parameters:
aAllowSubclasses - whether subclass of another declared exception is allowed in throws clause


setAllowUnchecked

public void setAllowUnchecked(boolean aAllowUnchecked)
Getter for allowUnchecked property.

Parameters:
aAllowUnchecked - whether unchecked excpetions in throws are allowed or not