Class IllegalBlockTagCheck

All Implemented Interfaces:
Configurable, Contextualizable

public class IllegalBlockTagCheck extends AbstractJavadocCheck
Detects a user-defined Javadoc block tag and reports a violation when the tag is present with text that does not match tagTextPattern. With the default pattern ^$ (same as Regexp format default; matches only empty content), any non-empty text of the configured tag is a violation. No violation is reported when there is no Javadoc or when tag is not configured.
Since:
13.10.0
  • Field Details

    • MSG_ILLEGAL_PATTERN

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

      private static final Pattern MATCH_NOTHING
      Pattern that matches only empty content (Regexp format default).
    • tagTextPattern

      private Pattern tagTextPattern
      Specify the regexp that tag content is allowed to match.
    • tag

      @Nullable private String tag
      Specify the name of tag.
  • Constructor Details

    • IllegalBlockTagCheck

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

    • setTag

      public void setTag(String tag)
      Setter to specify the name of tag.
      Parameters:
      tag - tag to check
      Since:
      13.10.0
    • setTagTextPattern

      public void setTagTextPattern(Pattern pattern)
      Setter to specify the regexp that tag content is allowed to match. Content that does not match is treated as illegal.
      Parameters:
      pattern - a Pattern value
      Since:
      13.10.0
    • 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:
      13.10.0
    • 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:
    • 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:
    • 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
    • getTagContent

      private static String getTagContent(DetailNode javadocBlockTagNode)
      Returns the raw content of the tag.
      Parameters:
      javadocBlockTagNode - The node representing a Javadoc block tag. This node must be of type JavadocCommentsTokenTypes.JAVADOC_BLOCK_TAG
      Returns:
      The raw content of the tag.
    • findJavadoc

      @Nullable private static DetailAST findJavadoc(DetailAST ast)
      Finds the Javadoc comment associated with a structural AST node.
      Parameters:
      ast - the structural node (e.g., CLASS_DEF, METHOD_DEF)
      Returns:
      the Javadoc block comment if found, or null