## com.puppycrawl.tools.checkstyle.checks.javadoc
Class JavadocMethodCheck

    java.lang.Object
      com.puppycrawl.tools.checkstyle.api.AutomaticBean
          com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
              com.puppycrawl.tools.checkstyle.api.Check
                  com.puppycrawl.tools.checkstyle.checks.AbstractTypeAwareCheck
                      com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMethodCheck

All Implemented Interfaces:
  Configurable, Contextualizable

public class JavadocMethodCheck
extends AbstractTypeAwareCheck

Checks the Javadoc of a method or constructor. By default, does not check for unused throws. To allow documented `java.lang.RuntimeException`s 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

Nested Class Summary

Nested classes inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractTypeAwareCheck
`AbstractTypeAwareCheck.ClassInfo`

Constructor Summary
`JavadocMethodCheck()` Create an object.

Method Summary
`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.
`protected void` `logLoadError(FullIdent aIdent)` Logs error if unable to load class information.
`protected void` `processAST(DetailAST aAST)` Checks Javadoc comments for a method or constructor.
`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` `setExcludeScope(java.lang.String aScope)` Set the excludeScope.
`void` `setScope(java.lang.String aFrom)` Set the scope.

Methods inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractTypeAwareCheck
`beginTree, getCurrentClassName, isSameType, isShortName, isSubclass, isUnchecked, leaveToken, resolveClass, tryLoadClass, visitToken`

Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
`destroy, finishTree, getClassLoader, getFileContents, getLines, getTabWidth, getTokenNames, init, 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, 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()

  Create an object.

Method Detail

### setScope

    public void setScope(java.lang.String aFrom)

  Set the scope.

  Parameters:
    `aFrom` - a `String` value

### setExcludeScope

    public void setExcludeScope(java.lang.String aScope)

  Set the excludeScope.

  Parameters:
    `aScope` - 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`

### processAST

    protected final void processAST(DetailAST aAST)

  Checks Javadoc comments for a method or constructor.

  Specified by:
    `processAST` in class `AbstractTypeAwareCheck`
  Parameters:
    `aAST` - the tree node for the method or constructor.

### logLoadError

    protected final void logLoadError(FullIdent aIdent)

  Logs error if unable to load class information.

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

Back to the Checkstyle Home Page