Class InappropriateJavadocBlockTagsOnFieldCheck

All Implemented Interfaces:
Configurable, Contextualizable

public class InappropriateJavadocBlockTagsOnFieldCheck extends AbstractJavadocCheck
Checks that Javadoc block tags for field declarations do not contain tags that are semantically invalid for fields. Specifically, @author, @version, @param, @return, @throws/@exception, @uses, and @provides tags are meaningless on field declarations.

Field declarations do not have parameters, return types, or throw declarations, and module/type-level tags like @author, @version, @uses, and @provides are inappropriate on field declarations. Therefore, such Javadoc block tags are considered inappropriate and should be removed.

Since:
14.1.0
  • Field Details

    • MSG_KEY

      public static final String MSG_KEY
      A key is pointing to the warning message text in "messages.properties" file.
      See Also:
    • currentAst

      private DetailAST currentAst
      Java AST node whose attached Javadoc is currently being processed.
  • Constructor Details

    • InappropriateJavadocBlockTagsOnFieldCheck

      public InappropriateJavadocBlockTagsOnFieldCheck()
      Creates a new InappropriateJavadocBlockTagsOnFieldCheck instance.
  • Method Details

    • setViolateExecutionOnNonTightHtml

      public void setViolateExecutionOnNonTightHtml(boolean shouldReportViolation)
      Setter to control when to print violations if the Javadoc being examined by this check violates the tight html rules defined at Tight-HTML Rules.
      Overrides:
      setViolateExecutionOnNonTightHtml in class AbstractJavadocCheck
      Parameters:
      shouldReportViolation - value to which the field shall be set to
      Since:
      14.1.0
    • getDefaultTokens

      public int[] getDefaultTokens()
      Description copied from class: AbstractCheck
      Returns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.
      Overrides:
      getDefaultTokens in class AbstractJavadocCheck
      Returns:
      the default tokens
      See Also:
    • getRequiredTokens

      public int[] getRequiredTokens()
      Description copied from class: AbstractCheck
      The tokens that this check must be registered for.
      Overrides:
      getRequiredTokens in class AbstractJavadocCheck
      Returns:
      the token set this must be registered for.
      See Also:
    • getAcceptableTokens

      public int[] getAcceptableTokens()
      Description copied from class: AbstractCheck
      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 AbstractJavadocCheck
      Returns:
      the token set this check is designed for.
      See Also:
    • getDefaultJavadocTokens

      public int[] getDefaultJavadocTokens()
      Description copied from class: AbstractJavadocCheck
      Returns the default javadoc token types a check is interested in.
      Specified by:
      getDefaultJavadocTokens in class AbstractJavadocCheck
      Returns:
      the default javadoc token types
      See Also:
    • getRequiredJavadocTokens

      public int[] getRequiredJavadocTokens()
      Description copied from class: AbstractJavadocCheck
      The javadoc tokens that this check must be registered for.
      Overrides:
      getRequiredJavadocTokens in class AbstractJavadocCheck
      Returns:
      the javadoc token set this must be registered for.
      See Also:
    • visitToken

      public void visitToken(DetailAST ast)
      Description copied from class: AbstractCheck
      Called to process a token.
      Overrides:
      visitToken in class AbstractJavadocCheck
      Parameters:
      ast - the token to process
    • visitJavadocToken

      public void visitJavadocToken(DetailNode ast)
      Description copied from class: AbstractJavadocCheck
      Called to process a Javadoc token.
      Specified by:
      visitJavadocToken in class AbstractJavadocCheck
      Parameters:
      ast - the token to process
    • getTagName

      private static String getTagName(DetailNode ast)
      Returns the tag name corresponding to the given Javadoc token type.
      Parameters:
      ast - the Javadoc token
      Returns:
      the tag name as a string
      Throws:
      IllegalArgumentException - if the token type is not recognized as a Javadoc block tag that is inappropriate for field declarations.