JavadocParagraph

Since Checkstyle 6.0

Description

Checks the Javadoc paragraph.

Checks that:

  • There is one blank line between each of two paragraphs.
  • Each paragraph but the first has <p> immediately before the first word, with no space after.

Properties

name description type default value since
allowNewlineParagraph Control whether the <p> tag should be placed immediately before the first word. boolean true 6.9
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 8.3

Examples

To configure the default check:

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

By default, the check will report a violation if there is a new line or whitespace after the <p> tag:

/**
 * No tag (ok).
 *
 * <p>Tag immediately before the text (ok).
 * <p>No blank line before the tag (violation).
 *
 * <p>
 * New line after tag (violation).
 *
 * <p> Whitespace after tag (violation).
 *
 */
public class TestClass {
}
        

To allow newlines and spaces immediately after the <p> tag:

<module name="Checker">
  <module name="TreeWalker">
    <module name="JavadocParagraph">
      <property name="allowNewlineParagraph" value="false"/>
    </module>
  </module>
</module>
        

In case of allowNewlineParagraph set to false the following example will not have any violations:

/**
 * No tag (ok).
 *
 * <p>Tag immediately before the text (ok).
 * <p>No blank line before the tag (violation).
 *
 * <p>
 * New line after tag (ok).
 *
 * <p> Whitespace after tag (ok).
 *
 */
public class TestClass {
}
        

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.

Package

com.puppycrawl.tools.checkstyle.checks.javadoc

Parent Module

TreeWalker