Skip to content

Add Check Support for Java 21 Unnamed Variables & Patterns Syntax: Javadoc Checks #15110

@mahfouz72

Description

@mahfouz72

child of #14942

AtclauseOrderCheck

doc : https://checkstyle.org/checks/javadoc/atclauseorder.html

Checks the order of javadoc tags

the targeted variable definition here is the variable definition that is a class field only. and since the unnamed variables can't be class field then this check is completely unrelated.


JavadocStyleCheck

doc : https://checkstyle.org/checks/javadoc/javadocstyle.html

Validates Javadoc comments to help ensure they are well formed.

the targeted variable definition here is the variable definition that is a class field only. and since the unnamed variables can't be class field then this check is completely unrelated.


JavadocVariable

doc : https://checkstyle.org/checks/javadoc/javadocvariable.html

Checks that a variable has a Javadoc comment.

the targeted variable definition here is the variable definition that is a class field only. and since the unnamed variables can't be class field then this check is completely unrelated.


Example:

PS D:\CS\test> javac src/Test.java                                              
PS D:\CS\test> cat config.xml                                                   
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
        "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
        "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
    <property name="charset" value="UTF-8"/>
    <module name="TreeWalker">
               <module name="JavadocStyle">
        </module>
    </module>
</module>
PS D:\CS\test> cat src/Test.java                                                
public class Test {

    /**
     * Some description here             // violation
     */
    int i = 0;

    public void test() {
        /**
         * Some description here
         */
        int _ = 0;  // this is not being checked because it is not a class field

    }
}
PS D:\CS\test> java  -jar checkstyle-10.17.0-all.jar -c config.xml src/Test.java
Starting audit...
[ERROR] D:\CS\test\src\Test.java:3: First sentence should end with a period. [JavadocStyle]
Audit done.
Checkstyle ends with 1 errors.
PS D:\CS\test> 


InvalidJavadocPosition

doc : https://checkstyle.org/checks/javadoc/invalidjavadocposition.html#InvalidJavadocPosition

The check violates the invalid Javadoc position on the unnamed variables (local variable) so it works as intended.


$ cat TestClass.java
public class Test {

    /**
     * Some description here             // violation
     */
    int i = 0;

    public void test() {
        /**
         * Some description here
         */
        int _ = 0;  // this is not being checked because it is not a class field

    }
}

$ cat TestConfig.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="InvalidJavadocPosition"/>
  </module>
</module>

$ java -jar checkstyle-10.17.0-all.jar -c TestConfig.xml TestClass.java
Starting audit...
[ERROR] TestClass.java:9:9: Javadoc comment is placed in the wrong location. [InvalidJavadocPosition]
Audit done.
Checkstyle ends with 1 errors.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions