child of #14942
I have read check documentation: https://checkstyle.org/checks/naming/patternvariablename.html
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
record Point(int x, int y) { }
record square(Point upperLeft, Point lowerRight) { }
public class PatternVariables {
void method(Object obj) {
if (obj instanceof square(Point(int _, int y), _)) { // violation
System.out.println(y);
}
}
}
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="PatternVariableName">
</module>
</module>
</module>
PS D:\CS\test> java -jar checkstyle-10.14.2-all.jar -c config.xml src/PatternVariables.java
Starting audit...
[ERROR] D:\CS\test\src\PatternVariables.java:6:45: Name '_' must match pattern '^[a-z][a-zA-Z0-9]*$'. [PatternVariableName]
Audit done.
Checkstyle ends with 1 errors.
Describe what you expect in detail.
PatternVariableName should allow unnamed pattern variables by default
child of #14942
I have read check documentation: https://checkstyle.org/checks/naming/patternvariablename.html
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
Describe what you expect in detail.
PatternVariableNameshould allow unnamed pattern variables by default