-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
JavadocStyle doesn't work with inline @return #12600
Copy link
Copy link
Closed
Description
I have read check documentation: https://checkstyle.org/config_javadoc.html#JavadocStyle
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words
C:\Users\Juuz>javac Test.java
C:\Users\Juuz>type checkstyle.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="JavadocStyle"/>
</module>
</module>
C:\Users\Juuz>type Test.java
class Test {
/**
* {@return a string}
*/
String foo() {
return "Hello, world";
}
}
C:\Users\Juuz>set RUN_LOCALE="-Duser.language=en -Duser.country=US"
C:\Users\Juuz>java %RUN_LOCALE% -jar Downloads\checkstyle-10.6.0-all.jar -c checkstyle.xml Test.java
Starting audit...
[ERROR] C:\Users\Juuz\Test.java:2: First sentence should end with a period. [JavadocStyle]
Audit done.
Checkstyle ends with 1 errors.JavadocStyle requires a period after the first sentence, but it doesn't consider inline {@return} tags which insert a period after the contents.
For the example file with {@return a string}, this is what javadoc -package Test.java (JDK 19) generates:
This seems to be related to #10776, which is a similar issue with a different check.
Note: A workaround is to add a . after the {@return} tag.
Reactions are currently unavailable

