Since Checkstyle 6.0
Checks the Javadoc paragraph.
Checks that:
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 |
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:
// violation 5 lines below '<p> tag should be preceded with an empty line' /** * 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). * */ // violation 3 lines above 'tag should be placed immediately before the first word' public class Example1 { }
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:
// violation 5 lines below '<p> tag should be preceded with an empty line' /** * No tag (ok). * * <p>Tag immediately before the text (ok). * <p>No blank line before the tag. * * <p> * New line after tag (ok). * * <p> Whitespace after tag (ok). * */ // violation 6 lines above 'tag should be placed immediately before the first word' // violation 4 lines above 'tag should be placed immediately before the first word' public class Example2 { }
All messages can be customized if the default message doesn't suit you. Please see the documentation to learn how to.
com.puppycrawl.tools.checkstyle.checks.javadoc