com.puppycrawl.tools.checkstyle.checks.coding
Class RedundantThrowsCheck

java.lang.Object
  extended by com.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended by com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended by com.puppycrawl.tools.checkstyle.api.Check
              extended by com.puppycrawl.tools.checkstyle.checks.AbstractTypeAwareCheck
                  extended by com.puppycrawl.tools.checkstyle.checks.coding.RedundantThrowsCheck
All 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, AbstractTypeAwareCheck.Token
 
Constructor Summary
RedundantThrowsCheck()
           
 
Method Summary
 int[] getDefaultTokens()
          Returns the default token a check is interested in.
protected  void logLoadError(AbstractTypeAwareCheck.Token aIdent)
          Logs error if unable to load class information.
protected  void processAST(DetailAST aAST)
          Called to process an AST when visiting it.
 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, createClassInfo, findClassAlias, getCurrentClassName, getRequiredTokens, isSubclass, isUnchecked, leaveAST, leaveToken, logLoadErrorImpl, resolveClass, setLogLoadErrors, setSuppressLoadErrors, tryLoadClass, visitToken
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLines, getTabWidth, getTokenNames, init, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, log, setId, setSeverity
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RedundantThrowsCheck

public RedundantThrowsCheck()
Method Detail

setAllowUnchecked

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

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

setAllowSubclasses

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

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

getDefaultTokens

public int[] getDefaultTokens()
Description copied from class: Check
Returns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.

Specified by:
getDefaultTokens in class Check
Returns:
the default tokens
See Also:
TokenTypes

processAST

protected final void processAST(DetailAST aAST)
Description copied from class: AbstractTypeAwareCheck
Called to process an AST when visiting it.

Specified by:
processAST in class AbstractTypeAwareCheck
Parameters:
aAST - the AST to process. Guaranteed to not be PACKAGE_DEF or IMPORT tokens.

logLoadError

protected final void logLoadError(AbstractTypeAwareCheck.Token aIdent)
Description copied from class: AbstractTypeAwareCheck
Logs error if unable to load class information. Abstract, should be overrided in subclasses.

Specified by:
logLoadError in class AbstractTypeAwareCheck
Parameters:
aIdent - class name for which we can no load class.

Back to the Checkstyle Home Page