Skip to content

Add Check Support for Java 21 Unnamed Variables & Patterns Syntax: NoWhitespaceAfter #15224

@mahfouz72

Description

@mahfouz72

child of #14942
Check doc: https://checkstyle.org/checks/whitespace/nowhitespaceafter.html#NoWhitespaceAfter


D:\CS\test
javac src/Test.java
D:\CS\test
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="NoWhitespaceAfter">

    </module>
  </module>
</module>
D:\CS\test
cat src/Test.java
public class Test {
    void m(Object o) {
        if (o instanceof ColoredPoint(int x, _   , String c) ) {}
    }
    record ColoredPoint(int x, int y   , String c) { }
}
D:\CS\test
java  -jar checkstyle-10.17.0-all.jar -c config.xml src/Test.java
Starting audit...
Audit done.


Describe what you want in detail.

This check's behavior is correct, we can just add a new test case for unnamed variables. The check doesn't enforce no whitespace after int y then space after _ should not violation

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions