Child of #8452
Check documentation: https://checkstyle.sourceforge.io/config_javadoc.html#MissingJavadocMethod
From check documentation:
Checks for missing Javadoc comments for a method or constructor. The scope to verify is specified using the Scope class and defaults to Scope.PUBLIC. To verify another scope, set property scope to a different scope.
➜ full-record-grammar /usr/lib/jvm/java-14-openjdk/bin/javac --enable-preview --source 14 TestClass.java
Note: TestClass.java uses preview language features.
Note: Recompile with -Xlint:preview for details.
➜ full-record-grammar cat config.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="MissingJavadocMethod"/>
</module>
</module>
➜ full-record-grammar cat TestClass.java
public class TestClass {
public record MyRecord(Integer number) {
private static int mNumber;
// not javadoc
public void setNumber(final int number)
{
mNumber = number;
} // violation
public int getNumber()
{
return mNumber;
}// violation
public void setNumber1()
{
mNumber = mNumber;
} // violation
}
public record MySecondRecord() {
// not a javadoc comment on compact ctor
public MySecondRecord{} // should be violation
}
public record MyThirdRecord() {
// not a javadoc comment on ctor
public MyThirdRecord(){} // violation
}
public void setNumber1() // violation
{
}
}
➜ full-record-grammar java $RUN_LOCALE -jar ~/IdeaProjects/checkstyle/target/checkstyle-8.35-SNAPSHOT-all.jar -c config.xml TestClass.java
Starting audit...
[ERROR] /home/nick/Desktop/full-record-grammar/TestClass.java:6:9: Missing a Javadoc comment. [MissingJavadocMethod]
[ERROR] /home/nick/Desktop/full-record-grammar/TestClass.java:11:9: Missing a Javadoc comment. [MissingJavadocMethod]
[ERROR] /home/nick/Desktop/full-record-grammar/TestClass.java:16:9: Missing a Javadoc comment. [MissingJavadocMethod]
[ERROR] /home/nick/Desktop/full-record-grammar/TestClass.java:29:9: Missing a Javadoc comment. [MissingJavadocMethod]
[ERROR] /home/nick/Desktop/full-record-grammar/TestClass.java:32:5: Missing a Javadoc comment. [MissingJavadocMethod]
Audit done.
Checkstyle ends with 5 errors.
We see that this check works within the body of record definitions, but does not work on compact constructors. We need to add support for compact constructors to this check.
Child of #8452
Check documentation: https://checkstyle.sourceforge.io/config_javadoc.html#MissingJavadocMethod
From check documentation:
Checks for missing Javadoc comments for a method or constructor. The scope to verify is specified using the Scope class and defaults to Scope.PUBLIC. To verify another scope, set property scope to a different scope.
We see that this check works within the body of record definitions, but does not work on compact constructors. We need to add support for compact constructors to this check.