Skip to content

ParenPad incorretly flags unsupported token #14747

@mahfouz72

Description

@mahfouz72

Should be considered with #4175

I have read check documentation: https://checkstyle.org/checks/whitespace/parenpad.html#ParenPad
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

PS D:\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="ParenPad"/>
    </module>
</module>

PS D:\test> cat src/Main.java
import static java.lang.StringTemplate.STR;
record ColoredPoint(int x, int y, String c) {
}
record Rectangle(ColoredPoint upperLeft, ColoredPoint lowerRight) {
}

public class Main {
    public static void main(String[] args) {
        ColoredPoint cp = new ColoredPoint(1, 2, "red");
        Rectangle r = new Rectangle(cp, new ColoredPoint(3, 4, "blue"));
        printUpperLeftColoredPoint(r);

    }
    static void printUpperLeftColoredPoint(Object obj) {
            if (obj instanceof Rectangle(  ColoredPoint(_, int y, _), _)) {  // violation
                System.out.println(y);
            }
        }
}
PS D:\test> java  -jar checkstyle-10.14.2-all.jar -c config.xml  src/Main.java
Starting audit...
[ERROR] D:\test\src\Main.java:15:41: '(' is followed by whitespace. [ParenPad]
Audit done.
Checkstyle ends with 1 errors.
PS D:\test> 

Describe what you expect in detail.
no violation as RECORD_PATTERN token is not supported in the check .

Note: Check supports token RECORD_DEF .

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions