I have read the check documentation: https://checkstyle.org/checks/misc/indentation.html
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the CLI and pasted its output below, as the output describes the problem better than 1,000 words.
$ cat example-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="Indentation"/>
</module>
</module>
$ cat Example.java
class Example {
void foo() {
int i = 0;
int j = switch (i) {
case 0 -> {
yield switch (i) {
case 0 -> 0; // error: expected level should be 24
default -> 1; // error: expected level should be 24
}; // error: expected level should be 20
}
default -> 1;
};
}
}
$ RUN_LOCALE="-Duser.language=en -Duser.country=US"
$ java $RUN_LOCALE -jar checkstyle-13.4.0-all.jar -c example-config.xml Example.java
Starting audit...
[ERROR] /tmp/Example.java:7:21: 'case' child has incorrect indentation level 20, expected level should be 24. [Indentation]
[ERROR] /tmp/Example.java:8:21: 'case' child has incorrect indentation level 20, expected level should be 24. [Indentation]
[ERROR] /tmp/Example.java:9:17: 'switch rcurly' has incorrect indentation level 16, expected level should be 20. [Indentation]
Audit done.
Checkstyle ends with 3 errors.
Expected behaviour:
The snippet
yield switch (i) {
case 0 -> 0;
default -> 1;
};
should already be formatted correctly. Instead, Checkstyle expects the snippet to be formatted as
yield switch (i) {
case 0 -> 0;
default -> 1;
};
I tried checking for duplicate issues; in particular, this seems similar to #17167 and #15967.
However, considering both issues are closed, I went ahead and opened a new one.
Thank you for maintaining this project!
I have read the check documentation: https://checkstyle.org/checks/misc/indentation.html
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the CLI and pasted its output below, as the output describes the problem better than 1,000 words.
$ cat example-config.xml$ cat Example.javaExpected behaviour:
The snippet
should already be formatted correctly. Instead, Checkstyle expects the snippet to be formatted as
I tried checking for duplicate issues; in particular, this seems similar to #17167 and #15967.
However, considering both issues are closed, I went ahead and opened a new one.
Thank you for maintaining this project!