com.puppycrawl.tools.checkstyle.checks
Class JavadocMethodCheck

java.lang.Object
  extended bycom.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended bycom.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended bycom.puppycrawl.tools.checkstyle.api.Check
              extended bycom.puppycrawl.tools.checkstyle.checks.AbstractImportCheck
                  extended bycom.puppycrawl.tools.checkstyle.checks.JavadocMethodCheck
All Implemented Interfaces:
Configurable, Contextualizable

public class JavadocMethodCheck
extends AbstractImportCheck

Checks the Javadoc of a method or constructor. By default, does not check for unused throws. To allow documented java.lang.RuntimeExceptions that are not declared, set property allowUndeclaredRTE to true. The scope to verify is specified using the Scope class and defaults to Scope.PRIVATE. To verify another scope, set property scope to one of the Scope constants.

Error messages about parameters for which no param tags are present can be suppressed by defining property allowMissingParamTags. Error messages about exceptions which are declared to be thrown, but for which no throws tag is present can be suppressed by defining property allowMissingThrowsTags. Error messages about methods which return non-void but for which no return tag is present can be suppressed by defining property allowMissingReturnTag.

An example of how to configure the check is:

 <module name="JavadocMethod"/>
 

An example of how to configure the check to check to allow documentation of undeclared RuntimeExceptions and for the Scope.PUBLIC scope, while ignoring any missing param tags is:

 <module name="JavadocMethod">
    <property name="scope" value="public"/>
    <property name="allowUndeclaredRTE" value="true"/>
    <property name="allowMissingParamTags" value="true"/>
 </module>
 

Version:
1.1
Author:
Oliver Burn, Rick Giles, o_sukhodoslky

Constructor Summary
JavadocMethodCheck()
           
 
Method Summary
 void beginTree(DetailAST aRootAST)
          Called before the starting to process a tree.
 int[] getAcceptableTokens()
          The configurable token set.
 int[] getDefaultTokens()
          Returns the default token a check is interested in.
 int[] getRequiredTokens()
          The tokens that this check must be registered for.
 void setAllowMissingParamTags(boolean aFlag)
          controls whether to allow a method which has parameters to omit matching param tags in the javadoc.
 void setAllowMissingReturnTag(boolean aFlag)
          controls whether to allow a method which returns non-void type to omit the return tag in the javadoc.
 void setAllowMissingThrowsTags(boolean aFlag)
          controls whether to allow a method which declares that it throws exceptions to omit matching throws tags in the javadoc.
 void setAllowThrowsTagsForSubclasses(boolean aFlag)
          controls whether to allow documented exception that are subclass of one of declared exceptions.
 void setAllowUndeclaredRTE(boolean aFlag)
          controls whether to allow documented exceptions that are not declared if they are a subclass of java.lang.RuntimeException.
 void setScope(java.lang.String aFrom)
          Set the scope.
 void visitToken(DetailAST aAST)
          Called to process a token.
 
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractImportCheck
getImportText
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
destroy, finishTree, getClassLoader, getFileContents, getLines, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, 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

JavadocMethodCheck

public JavadocMethodCheck()
Method Detail

setScope

public void setScope(java.lang.String aFrom)
Set the scope.

Parameters:
aFrom - a String value

setAllowUndeclaredRTE

public void setAllowUndeclaredRTE(boolean aFlag)
controls whether to allow documented exceptions that are not declared if they are a subclass of java.lang.RuntimeException.

Parameters:
aFlag - a Boolean value

setAllowThrowsTagsForSubclasses

public void setAllowThrowsTagsForSubclasses(boolean aFlag)
controls whether to allow documented exception that are subclass of one of declared exceptions.

Parameters:
aFlag - a Boolean value

setAllowMissingParamTags

public void setAllowMissingParamTags(boolean aFlag)
controls whether to allow a method which has parameters to omit matching param tags in the javadoc. Defaults to false.

Parameters:
aFlag - a Boolean value

setAllowMissingThrowsTags

public void setAllowMissingThrowsTags(boolean aFlag)
controls whether to allow a method which declares that it throws exceptions to omit matching throws tags in the javadoc. Defaults to false.

Parameters:
aFlag - a Boolean value

setAllowMissingReturnTag

public void setAllowMissingReturnTag(boolean aFlag)
controls whether to allow a method which returns non-void type to omit the return tag in the javadoc. Defaults to false.

Parameters:
aFlag - a Boolean value

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:
Check

getAcceptableTokens

public int[] getAcceptableTokens()
Description copied from class: Check
The configurable token set. Used to protect Checks against malicious users who specify an unacceptable token set in the configuration file. The default implementation returns the check's default tokens.

Overrides:
getAcceptableTokens in class Check
Returns:
the token set this check is designed for.
See Also:
Check

getRequiredTokens

public int[] getRequiredTokens()
Description copied from class: Check
The tokens that this check must be registered for.

Overrides:
getRequiredTokens in class Check
Returns:
the token set this must be registered for.
See Also:
Check

beginTree

public void beginTree(DetailAST aRootAST)
Description copied from class: Check
Called before the starting to process a tree. Ideal place to initialise information that is to be collected whilst processing a tree.

Overrides:
beginTree in class Check
Parameters:
aRootAST - the root of the tree
See Also:
Check

visitToken

public void visitToken(DetailAST aAST)
Description copied from class: Check
Called to process a token.

Overrides:
visitToken in class Check
Parameters:
aAST - the token to process
See Also:
Check

Back to the Checkstyle Home Page