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

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.javadoc.JavadocMethodCheck
All Implemented Interfaces:
Configurable, Contextualizable

public class JavadocMethodCheck
extends AbstractTypeAwareCheck

Checks the Javadoc of a method or constructor.

Author:
Oliver Burn, Rick Giles, o_sukhodoslky

Nested Class Summary
 
Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractTypeAwareCheck
AbstractTypeAwareCheck.ClassInfo, AbstractTypeAwareCheck.Token
 
Constructor Summary
JavadocMethodCheck()
           
 
Method Summary
 int[] getAcceptableTokens()
          The configurable token set.
 int[] getDefaultTokens()
          Returns the default token a check is interested in.
protected  boolean isMissingJavadocAllowed(DetailAST aAST)
          The JavadocMethodCheck is about to report a missing Javadoc.
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 setAllowMissingJavadoc(boolean aFlag)
          Controls whether to ignore errors when there is no javadoc.
 void setAllowMissingParamTags(boolean aFlag)
          controls whether to allow a method which has parameters to omit matching param tags in the javadoc.
 void setAllowMissingPropertyJavadoc(boolean aFlag)
          Controls whether to ignore errors when there is no javadoc for a property accessor (setter/getter methods).
 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, 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, 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

JavadocMethodCheck

public JavadocMethodCheck()
Method Detail

setScope

public void setScope(String aFrom)
Set the scope.

Parameters:
aFrom - a String value

setExcludeScope

public void setExcludeScope(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

setAllowMissingJavadoc

public void setAllowMissingJavadoc(boolean aFlag)
Controls whether to ignore errors when there is no javadoc. Defaults to false.

Parameters:
aFlag - a Boolean value

setAllowMissingPropertyJavadoc

public void setAllowMissingPropertyJavadoc(boolean aFlag)
Controls whether to ignore errors when there is no javadoc for a property accessor (setter/getter methods). 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:
TokenTypes

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

isMissingJavadocAllowed

protected boolean isMissingJavadocAllowed(DetailAST aAST)
The JavadocMethodCheck is about to report a missing Javadoc. This hook can be used by derived classes to allow a missing javadoc in some situations. The default implementation checks allowMissingJavadoc and allowMissingPropertyJavadoc properties, do not forget to call super.isMissingJavadocAllowed(aAST) in case you want to keep this logic.

Parameters:
aAST - the tree node for the method or constructor.
Returns:
True if this method or constructor doesn't need Javadoc.


Copyright © 2001-2012. All Rights Reserved.