Detailed Description is provided by @ksclarke .
Check documentation: https://checkstyle.org/config_misc.html#Indentation
$ cat Test.java
//package info.freelibrary.vertx.s3;
import java.util.function.Consumer;
public class Test {
public void testMethod() {
test(c1 -> {
System.out.println("c1");
}, c2 -> {
System.out.println("c2");
});
}
private void test(final Consumer aC1, final Consumer aC2) {
// just an example
}
}
Checkstyle config file:
$ cat checkstyle.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="severity" value="warning" />
<module name="TreeWalker">
<module name="Indentation">
<property name="throwsIndent" value="8" />
</module>
</module>
</module>
Running Checkstyle audit:
$ RUN_LOCALE="-Duser.language=en -Duser.country=US"
$ java $RUN_LOCALE -jar checkstyle-8.33-all.jar -c checkstyle.xml /Test.java
Starting audit...
[WARN] Test.java:12: 'block' child has incorrect indentation level 12, expected level should be 16. [Indentation]
[WARN] Test.java:13: 'block rcurly' has incorrect indentation level 8, expected level should be 12. [Indentation]
Audit done.
My expectation is that this should pass the audit with no warnings. The second function passed to the method shouldn't be indented any further than the first one.
I think I have the same issue so will just update on this ticket rather than create a new one.
Fixed with https://github.com/checkstyle/checkstyle/pull/8719
$ cat Test.java
//package info.freelibrary.vertx.s3;
import java.util.function.Consumer;
public class Test {
public void testMethod() {
test(c1 -> {
System.out.println("c1");
}, c2 -> {
System.out.println("c2");
});
}
private void test(final Consumer aC1, final Consumer aC2) {
// just an example
}
}
config.xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/>
<module name="FileTabCharacter">
<property name="eachLine" value="true"/>
</module>
<module name="TreeWalker">
<module name="Indentation">
<property name="throwsIndent" value="8"/>
</module>
</module>
</module>
output:
java -jar checkstyle-8.36.2-all.jar -c config.xml Test.java
Starting audit...
Audit done.
fixed in scope of https://github.com/checkstyle/checkstyle/issues/3342, released in 8.36.2