checkstyle / checkstyle/checkstyle
Indentation is incorrect with line wrapping and nested parentheses (method calls)
- Dominant language
- Java
- Stars
- 9.6k
- Forks
- 4.2k
- Avg merge
- 20h 33m
- Merged PRs (30d)
- 234
Description
```
$ javac IndentationWithNestedMethodCalls.java
$
$ cat config.xml
$ cat IndentationWithNestedMethodCalls.java
import java.util.*;
public class IndentationWithNestedMethodCalls {
public static void main(String[] args) {
Arrays.asList(true,
true,
Arrays.asList(true,
true, // Violation, line 8
true)); // Violation, line 9
Arrays.asList(true,
true,
Arrays.asList(true,
true, // No violation, but should be
true)); // No violation, but should be.
// Works correctly with arrays/curly braces.
Object[] array = new Object[] {
1,
new Object[] {
1,
2,
3
},
new Object[] {
1,
2,
new Object[] {
1,
2
}
}
};
}
}
$ RUN_LOCALE="-Duser.language=en -Duser.country=US"
$ java $RUN_LOCALE -jar checkstyle-8.11-all.jar -c config.xml IndentationWithNestedMethodCalls.java
Starting audit...
[ERROR] /private/tmp/IndentationWithNestedMethodCalls.java:8: 'true' has incorrect indentation level 16, expected level should be 12. [Indentation]
[ERROR] /private/tmp/IndentationWithNestedMethodCalls.java:9: 'true' has incorrect indentation level 16, expected level should be 12. [Indentation]
Audit done.
Checkstyle ends with 2 errors.
```
---------------
When the argument to a method call is another method call, then the inner method should be further indented by the lineWrappingIndentation amount. Currently, it indents the inner method calls as continuations of the outer method.
The same type of nesting works correctly with arrays/curly braces.
--------------
Let me know if there are any questions!
Contributor guide
Research direction
Reproduce the report with IndentationWithNestedMethodCalls.java, config.xml, and the Indentation module using the provided Checkstyle command. Inspect how nested method-call arguments are indented compared with the working arrays/curly-brace case. Done means the nested calls receive the configured lineWrappingIndentation and the reported violations are detected correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100