I have read check documentation: https://checkstyle.sourceforge.io/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 showed it below, as cli describes the problem better than 1,000 words
/var/tmp $ javac Example.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="Indentation"/>
</module>
</module>
/var/tmp $ cat Example.java
import java.util.List;
class Example {
static void main() {
List.of("foo").stream()
.findFirst()
.ifPresentOrElse(
System.out::println,
() -> {
throw new IllegalStateException();
}
);
}
}
/var/tmp $ RUN_LOCALE="-Duser.language=en -Duser.country=US"
/var/tmp $ java $RUN_LOCALE -jar checkstyle-12.1.2-all.jar -c config.xml Example.java
Starting audit...
[ERROR] /var/tmp/Example.java:12:13: 'method call rparen' has incorrect indentation level 12, expected level should be 8. [Indentation]
Audit done.
Checkstyle ends with 1 errors.
Describe what you expect in detail.
There should be no errors.
In AnotherExample.java I've replaced List.of("foo").stream() with Stream.of("foo") and there are no errors:
/var/tmp $ javac AnotherExample.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="Indentation"/>
</module>
</module>
/var/tmp $ cat AnotherExample.java
import java.util.stream.Stream;
class AnotherExample {
static void main() {
Stream.of("foo")
.findFirst()
.ifPresentOrElse(
System.out::println,
() -> {
throw new IllegalStateException();
}
);
}
}
/var/tmp $ RUN_LOCALE="-Duser.language=en -Duser.country=US"
/var/tmp $ java $RUN_LOCALE -jar checkstyle-12.1.2-all.jar -c config.xml AnotherExample.java
Starting audit...
Audit done.
I have read check documentation: https://checkstyle.sourceforge.io/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 showed it below, as cli describes the problem better than 1,000 words
Describe what you expect in detail.
There should be no errors.
In
AnotherExample.javaI've replacedList.of("foo").stream()withStream.of("foo")and there are no errors: