-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
I have read check documentation: https://checkstyle.sourceforge.io/checks/whitespace/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
Code:
public class Test {
int sum(int a, int b, int c) {
return a
+ b // Expected Violation (and Reported)
+ c; // Expected Violation (and Reported)
}
java.util.function.Function<String, Integer> test_arrow() {
return (String s) ->
s.length(); // Expected Violation (but ignored)
}
int test_comma() {
return sum(
1, // Expected Violation (but ignored)
2, // Expected Violation (but ignored)
3 // Expected Violation (but ignored)
);
}
}Config:
<?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="localeLanguage" value="en"/>
<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>
Cli:
$ java -jar checkstyle-10.26.1-all.jar -c config.xml Test.java
Starting audit...
[ERROR] Test.java:4:5: 'method def' child has incorrect indentation level 4, expected level should be 8. [Indentation]
[ERROR] Test.java:5:5: 'method def' child has incorrect indentation level 4, expected level should be 8. [Indentation]
Audit done.
Checkstyle ends with 2 errors.
Observed behavior:
In return with +, indentation errors are correctly reported.
In return with lambda arrow -> or commas ,, no indentation violations are reported, even though they are also continuation lines.
This makes the behavior inconsistent: some continuation elements are checked, while others are ignored.