Class JavadocContentLocationCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable

    public class JavadocContentLocationCheck
    extends AbstractCheck

    Checks that the Javadoc content begins from the same position for all Javadoc comments in the project. Any leading asterisks and spaces are not counted as the beginning of the content and are therefore ignored.

    It is possible to enforce two different styles:

    • first_line - Javadoc content starts from the first line:
       /** Summary text.
         * More details.
         */
       public void method();
       
    • second_line - Javadoc content starts from the second line:
       /**
         * Summary text.
         * More details.
         */
       public void method();
       

    This check does not validate the Javadoc summary itself nor its presence. The check will not report any violations for missing or malformed javadoc summary. To validate the Javadoc summary use SummaryJavadoc check.

    The Documentation Comment Specification permits leading asterisks on the first line. For these Javadoc comments:

     /***
       * Some text.
       */
     /************
       * Some text.
       */
     /**           **
       * Some text.
       */
     

    The documentation generated will be just "Some text." without any asterisks. Since these asterisks will not appear in the generated documentation, they should not be considered as the beginning of the Javadoc content. In such cases, the check assumes that the Javadoc content begins on the second line.

    • Property location - Specify the policy on placement of the Javadoc content. Type is com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocContentLocationOption. Default value is second_line.

    Parent is com.puppycrawl.tools.checkstyle.TreeWalker

    Violation Message Keys:

    • javadoc.content.first.line
    • javadoc.content.second.line
    Since:
    8.27