JavadocLeadingAsteriskAlign

Since Checkstyle 10.18.0

Description

Checks the alignment of leading asterisks in a Javadoc comment. The Check ensures that leading asterisks are aligned vertically under the first asterisk ( * ) of opening Javadoc tag. The alignment of closing Javadoc tag ( */ ) is also checked. If a closing Javadoc tag contains non-whitespace character before it then it's alignment will be ignored. If the ending javadoc line contains a leading asterisk, then that leading asterisk's alignment will be considered, the closing Javadoc tag will be ignored.

If you're using tabs then specify the the tab width in the tabWidth property.

Properties

name description type default value since
violateExecutionOnNonTightHtml Control when to print violations if the Javadoc being examined by this check violates the tight html rules defined at Tight-HTML Rules. boolean false 10.18.0

Examples

To configure the check:


<module name="Checker">
  <module name="TreeWalker">
    <module name="JavadocLeadingAsteriskAlign" />
  </module>
</module>

Example:


// violation 2 lines below '1, expected is 2.'
/**
* Javadoc for class.
 */
public class Example1 {
  // violation 2 lines below '5, expected is 4.'
  /**
    * Javadoc for instance variable, over-indented.
   */
  private int wrongIndentField;

  /**
   * Javadoc for instance variable, correctly aligned.
   */
  private int goodIndentField;
  // violation 2 lines below '3, expected is 4.'
  /**
  *  Javadoc for method, under-indented.
  */
  private void wrongIndentMethod() {}
  // violation 2 lines above '3, expected is 4.'
  /**
   * Javadoc for method, correctly aligned.
   */
  private void goodIndentMethod() {}
  // violation 3 lines below '1, expected is 4.'
  /**
   Javadoc for constructor, missing leading asterisk alignment on closing tag.
*/
  private Example1() {}

  /**
   * Javadoc for constructor, correctly aligned.
   */
  public Example1(int value) {}

  private enum indentedEnum {
    // violation 2 lines below '5, expected is 6.'
    /**
    *  Wrong alignment for enum constant.
     */
    WRONG,

    /**
     * Correct alignment for enum constant.
     */
    GOOD
  }
}

Example of Usage

Violation Messages

All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.

Fully Qualified Name

com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocLeadingAsteriskAlignCheck

Use this fully qualified class name in configuration when an exact class reference is required.

Parent Module

TreeWalker