-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Closed
Description
https://checkstyle.org/checks/coding/finallocalvariable.html#FinalLocalVariable
/var/tmp $ javac test.java
# success
/var/tmp $ cat checkstyle.xml
<!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="FinalLocalVariable">
<property name="tokens" value="VARIABLE_DEF,PARAMETER_DEF"/>
</module>
</module>
</module>
/var/tmp $ cat YOUR_FILE.java
interface Test {
static void test(String param) {
String local = "";
System.out.println(param);
}
}
/var/tmp $ java -jar checkstyle-10.21.0-all.jar -c checkstyle.xml test.java
Starting audit...
[ERROR] /Users/jake/Projects/Minecraft/PaperMC/test.java:3:12: Variable 'local' should be declared final. [FinalLocalVariable]
Audit done.
Checkstyle ends with 1 errors.
The param
local variable in the static method inside the Test interface should be reported as needing the final
modifier which, if I'm understanding the documentation correctly, adding the PARAMETER_DEF
token to the FinalLocalVariable
check should do.
If I change Test
to a class
instead of interface
, it correctly reports both, so I'm guessing someone just forgot about methods inside of interfaces.