Class JavadocMissingLeadingAsteriskCheck

All Implemented Interfaces:
Configurable, Contextualizable

public class JavadocMissingLeadingAsteriskCheck extends AbstractJavadocCheck

Checks if the javadoc has leading asterisks on each line.

The check does not require asterisks on the first line, nor on the last line if it is blank. All other lines in a Javadoc should start with *, including blank lines and code blocks.

  • Property violateExecutionOnNonTightHtml - Control when to print violations if the Javadoc being examined by this check violates the tight html rules defined at Tight-HTML Rules. Type is boolean. Default value is false.

To configure the check:

 <module name="JavadocMissingLeadingAsterisk"/>
 

Example:

 /**
  * Valid Java-style comment.
  *
  * <pre>
  *   int value = 0;
  * </pre>
  */
 class JavaStyle {} // ok

 /** Valid Scala-style comment.
   * Some description here.
   **/
 class ScalaStyle {} // ok

 /** **
  * Asterisks on first and last lines are optional.
  * */
 class Asterisks {} // ok

 /** No asterisks are required for single-line comments. */
 class SingleLine {} // ok

 /** // violation on next blank line, javadoc has lines without leading asterisk.

  */
 class BlankLine {}

 /** Wrapped
     single-line comment */ // violation, javadoc has lines without leading asterisk.
 class Wrapped {}

 /**
  * <pre>
     int value; // violation, javadoc has lines without leading asterisk.
  * </pre>
  */
 class Code {}
 

Parent is com.puppycrawl.tools.checkstyle.TreeWalker

Violation Message Keys:

  • javadoc.missed.html.close
  • javadoc.missing.asterisk
  • javadoc.parse.rule.error
  • javadoc.wrong.singleton.html.tag
Since:
8.38
  • Field Details

    • MSG_MISSING_ASTERISK

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

    • JavadocMissingLeadingAsteriskCheck

      public JavadocMissingLeadingAsteriskCheck()
  • Method Details

    • 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:
    • getAcceptableJavadocTokens

      public int[] getAcceptableJavadocTokens()
      Description copied from class: AbstractJavadocCheck
      The configurable javadoc token set. Used to protect Checks against malicious users who specify an unacceptable javadoc token set in the configuration file. The default implementation returns the check's default javadoc tokens.
      Overrides:
      getAcceptableJavadocTokens in class AbstractJavadocCheck
      Returns:
      the javadoc 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:
    • visitJavadocToken

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

      private static DetailNode getNextNode(DetailNode detailNode)
      Gets next node in the ast (sibling or parent sibling for the last node).
      Parameters:
      detailNode - the node to process
      Returns:
      next node.
    • isLeadingAsterisk

      private static boolean isLeadingAsterisk(DetailNode detailNode)
      Checks whether the given node is a leading asterisk.
      Parameters:
      detailNode - the node to process
      Returns:
      true if the node is JavadocTokenTypes.LEADING_ASTERISK
    • isLastLine

      private static boolean isLastLine(DetailNode detailNode)
      Checks whether this node is the end of a Javadoc comment, optionally preceded by blank text.
      Parameters:
      detailNode - the node to process
      Returns:
      true if the node is JavadocTokenTypes.EOF