Add JavadocMissingWhitespaceAfterAsterisk

commit-id:2bb16049
This commit is contained in:
Paul Campbell 2021-08-13 10:57:58 +01:00
parent 1deee25d96
commit 82868e9632
8 changed files with 80 additions and 1 deletions

View file

@ -165,6 +165,7 @@ Rule|Level|Source|Enabled|Suppressible
[InterfaceTypeParameterName](#interfacetypeparametername)|naming|checkstyle|Yes| [InterfaceTypeParameterName](#interfacetypeparametername)|naming|checkstyle|Yes|
[JavadocMethod](#javadocmethod)|javadoc|checkstyle|| [JavadocMethod](#javadocmethod)|javadoc|checkstyle||
[JavadocMissingLeadingAsterisk](#javadocmissingleadingasterisk)|layout|checkstyle|Yes| [JavadocMissingLeadingAsterisk](#javadocmissingleadingasterisk)|layout|checkstyle|Yes|
[JavadocMissingWhitespaceAfterAsterisk](#javadocmissingwhitespaceafterasterisk)|layout|checkstyle|Yes|
[JavadocPackage](#javadocpackage)|javadoc|checkstyle|Yes| [JavadocPackage](#javadocpackage)|javadoc|checkstyle|Yes|
[JavadocParagraph](#javadocparagraph)|javadoc|checkstyle|Yes| [JavadocParagraph](#javadocparagraph)|javadoc|checkstyle|Yes|
[JavadocStyle](#javadocstyle)|javadoc|checkstyle|Yes| [JavadocStyle](#javadocstyle)|javadoc|checkstyle|Yes|
@ -1183,6 +1184,40 @@ class Wrapped {}
*/ */
class Code {} class Code {}
```` ````
#### [JavadocMissingWhitespaceAfterAsterisk](https://checkstyle.sourceforge.io/config_javadoc.html#JavadocMissingWhitespaceAfterAsterisk)
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.
Valid:
````java
/** This is valid single-line Javadoc. */
class TestClass {
/**
* This is valid Javadoc.
*/
void validJavaDocMethod() {
}
/** This is valid single-line Javadoc. */
void validSingleLineJavaDocMethod() {
}
}
````
Invalid:
````java
class TestClass {
/**
*This is invalid Javadoc.
*/
int invalidJavaDoc;
/**This is invalid single-line Javadoc. */
void invalidSingleLineJavaDocMethod() {
}
}
````
#### [JavadocPackage](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage) #### [JavadocPackage](http://checkstyle.sourceforge.net/config_javadoc.html#JavadocPackage)
Checks that each package has a `package-info.java` file. Checks that each package has a `package-info.java` file.

View file

@ -1566,4 +1566,10 @@ rules:
enabled: true enabled: true
source: CHECKSTYLE source: CHECKSTYLE
uri: https://checkstyle.sourceforge.io/config_misc.html#NoCodeInFile uri: https://checkstyle.sourceforge.io/config_misc.html#NoCodeInFile
-
name: JavadocMissingWhitespaceAfterAsterisk
parent: TREEWALKER
level: LAYOUT
enabled: true
source: CHECKSTYLE
uri: https://checkstyle.sourceforge.io/config_javadoc.html#JavadocMissingWhitespaceAfterAsterisk

View file

@ -0,0 +1,33 @@
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.
Valid:
````java
/** This is valid single-line Javadoc. */
class TestClass {
/**
* This is valid Javadoc.
*/
void validJavaDocMethod() {
}
/** This is valid single-line Javadoc. */
void validSingleLineJavaDocMethod() {
}
}
````
Invalid:
````java
class TestClass {
/**
*This is invalid Javadoc.
*/
int invalidJavaDoc;
/**This is invalid single-line Javadoc. */
void invalidSingleLineJavaDocMethod() {
}
}
````

View file

@ -55,6 +55,7 @@
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/>
</module><!-- /TreeWalker --> </module><!-- /TreeWalker -->

View file

@ -82,6 +82,7 @@
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/>
</module><!-- /TreeWalker --> </module><!-- /TreeWalker -->

View file

@ -101,6 +101,7 @@
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/>
</module><!-- /TreeWalker --> </module><!-- /TreeWalker -->

View file

@ -144,6 +144,7 @@
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCaseDefaultColonCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/>
</module><!-- /TreeWalker --> </module><!-- /TreeWalker -->

View file

@ -191,6 +191,7 @@
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingLeadingAsteriskCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.sizes.LambdaBodyLengthCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.sizes.LambdaBodyLengthCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/> <module name="com.puppycrawl.tools.checkstyle.checks.NoCodeInFileCheck"/>
<module name="com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocMissingWhitespaceAfterAsteriskCheck"/>
</module><!-- /TreeWalker --> </module><!-- /TreeWalker -->