com.puppycrawl.tools.checkstyle.checks.coding

Class RedundantThrowsCheck

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

Method Summary
int[]getDefaultTokens()
{@inheritDoc}
protected voidlogLoadError(Token aIdent)
Logs error if unable to load class information.
protected voidprocessAST(DetailAST aAST)
Checks exceptions declared in throws for a method or constructor.
voidsetAllowSubclasses(boolean aAllowSubclasses)
Getter for allowSubclasses property.
voidsetAllowUnchecked(boolean aAllowUnchecked)
Getter for allowUnchecked property.

Method Detail

getDefaultTokens

public int[] getDefaultTokens()
{@inheritDoc}

logLoadError

protected final void logLoadError(Token aIdent)
Logs error if unable to load class information.

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.

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