com.puppycrawl.tools.checkstyle.checks.javadoc

Class JavadocMethodCheck

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.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

Authors:
Oliver Burn
Rick Giles
o_sukhodoslky

Nested Class Summary

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

AbstractTypeAwareCheck.ClassInfo

Constructor Summary

JavadocMethodCheck()
Create an object.

Method Summary

int[]
getAcceptableTokens()
int[]
getDefaultTokens()
int[]
getRequiredTokens()
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(String aScope)
Set the excludeScope.
void
setScope(String aFrom)
Set the scope.

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

JavadocMethodCheck

public JavadocMethodCheck()
Create an object.

Method Details

getAcceptableTokens

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

See Also:
Check


getDefaultTokens

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

See Also:
Check


getRequiredTokens

public int[] getRequiredTokens()
Overrides:
getRequiredTokens 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 Javadoc comments for a method or constructor.
Overrides:
processAST in interface AbstractTypeAwareCheck

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


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


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


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


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


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


setExcludeScope

public void setExcludeScope(String aScope)
Set the excludeScope.

Parameters:
aScope - a String value


setScope

public void setScope(String aFrom)
Set the scope.

Parameters:
aFrom - a String value