I have read check documentation: https://checkstyle.sourceforge.io/checks/naming/localfinalvariablename.html#LocalFinalVariableName
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
/var/tmp $ javac Test.java
/var/tmp $ 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="LocalFinalVariableName"/>
</module>
</module>
/var/tmp $ cat Test.java
public class Test {
public void foo() {
try (var _ = lock()) {
} catch (Exception exception) {
}
}
public AutoCloseable lock() {
return null;
}
}
/var/tmp $ RUN_LOCALE="-Duser.language=en -Duser.country=US"
/var/tmp $ java $RUN_LOCALE -jar checkstyle-X.XX-all.jar -c config.xml Test.java
Starting audit...
[ERROR] /home/boris/Test.java:3:26: Name '_' must match pattern '^[a-z][a-zA-Z0-9]*$'. [LocalFinalVariableName]
Audit done.
Checkstyle ends with 1 errors.
_ is a valid identifier in Java 22 and should be supported by Checkstyle. I fixed it locally by using <property name="format" value="^(_|[a-z][a-zA-Z0-9]*)$"/>.
I have read check documentation: https://checkstyle.sourceforge.io/checks/naming/localfinalvariablename.html#LocalFinalVariableName
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
_is a valid identifier in Java 22 and should be supported by Checkstyle. I fixed it locally by using<property name="format" value="^(_|[a-z][a-zA-Z0-9]*)$"/>.