-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Description
I have read the documentation: https://checkstyle.org/checks/misc/indentation.html#Indentation
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 -cp src/main/java src/main/java/com/example/checkstyledemo/Bar.java
... compiles successfully
/var/tmp $ cat config/checkstyle/checkstyle.yml
<?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">
<property name="charset" value="UTF-8"/>
<property name="severity" value="${org.checkstyle.google.severity}" default="warning"/>
<property name="fileExtensions" value="java"/>
<module name="TreeWalker">
<module name="Indentation">
<property name="basicOffset" value="2"/>
<property name="braceAdjustment" value="2"/>
<property name="caseIndent" value="2"/>
<property name="throwsIndent" value="4"/>
<property name="lineWrappingIndentation" value="4"/>
<property name="arrayInitIndent" value="2"/>
</module>
</module>
</module>
/var/tmp $ cat src/main/java/com/example/checkstyledemo/Bar.java
package com.example.checkstyledemo;
@AnnotList({
@Annot(
"hello"
),
@Annot(
"world"
)
})
public class Bar {
}
/var/tmp $ RUN_LOCALE="-Duser.language=en -Duser.country=US"
/var/tmp $ java $RUN_LOCALE -jar checkstyle-10.24.0-all.jar -c config/checkstyle/checkstyle.xml src/main/java/com/example/checkstyledemo/Bar.java
Starting audit...
[WARN] Bar.java:9:5: 'annotation array initialization' child has incorrect indentation level 4, expected level should be one of the following: 6, 8. [Indentation]
[WARN] Bar.java:12:5: 'annotation array initialization' child has incorrect indentation level 4, expected level should be one of the following: 6, 8. [Indentation]
Audit done.
I have also created a reproducer repository based on Spring linked here https://github.com/s-ste/checkstyle-indentation-reproducer
Hi everybody, I recently upgraded Checkstyle from 10.23.1 to 10.24.0, and now I get warnings that the linked code doesn't follow the rules anymore. I've compared my code to the release notes and found some parts related to fixes in indentation, but I don't see a direct connection so far.
I would expect Checkstyle to continue accepting the above code or make it configurable to allow this. Maybe I'm missing something, but to me it doesn't make much sense to indent the closing parenthesis here.
google checks config of indentation is same:
checkstyle/src/main/resources/google_checks.xml
Lines 300 to 307 in 60e9f19
<module name="Indentation"> | |
<property name="basicOffset" value="2"/> | |
<property name="braceAdjustment" value="2"/> | |
<property name="caseIndent" value="2"/> | |
<property name="throwsIndent" value="4"/> | |
<property name="lineWrappingIndentation" value="4"/> | |
<property name="arrayInitIndent" value="2"/> | |
</module> |
Metadata
Metadata
Assignees
Type
Projects
Status