Class JavadocMissingWhitespaceAfterAsteriskCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable

    public class JavadocMissingWhitespaceAfterAsteriskCheck
    extends AbstractJavadocCheck

    Checks that there is at least one whitespace after the leading asterisk. Although spaces after asterisks are optional in the Javadoc comments, their absence makes the documentation difficult to read. It is the de facto standard to put at least one whitespace after the leading asterisk.

    • 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 default check:

     <module name="JavadocMissingWhitespaceAfterAsterisk"/>
     

    Code Example:

     /** This is valid single-line Javadoc. */
     class TestClass {
       /**
         *This is invalid Javadoc.
         */
       int invalidJavaDoc;
       /**
         * This is valid Javadoc.
         */
       void validJavaDocMethod() {
       }
       /**This is invalid single-line Javadoc. */
       void invalidSingleLineJavaDocMethod() {
       }
       /** This is valid single-line Javadoc. */
       void validSingleLineJavaDocMethod() {
       }
     }
     

    Parent is com.puppycrawl.tools.checkstyle.TreeWalker

    Violation Message Keys:

    • javadoc.missed.html.close
    • javadoc.missing.whitespace
    • javadoc.parse.rule.error
    • javadoc.wrong.singleton.html.tag
    Since:
    8.32
    • Field Detail

      • MSG_KEY

        public static final java.lang.String MSG_KEY
        A key is pointing to the warning message text in "messages.properties" file.
        See Also:
        Constant Field Values
    • Constructor Detail

      • JavadocMissingWhitespaceAfterAsteriskCheck

        public JavadocMissingWhitespaceAfterAsteriskCheck()
    • Method Detail

      • isLast

        private static boolean isLast​(int position,
                                      java.lang.String text)
        Checks if the character position is the last one of the string.
        Parameters:
        position - the position of the character
        text - String literal.
        Returns:
        true if the character position is the last one of the string.
      • getLastLeadingAsteriskPosition

        private static int getLastLeadingAsteriskPosition​(java.lang.String text)
        Finds the position of the last leading asterisk in the string. If text contains no leading asterisk, -1 will be returned.
        Parameters:
        text - String literal.
        Returns:
        the index of the last leading asterisk.