checkstyle / checkstyle/checkstyle

Indentation: Checkstyle reports errors on correctly formatted nested / fluent code

Open
#3,779 1 comment 2 reactions 0 assignees View on GitHub
approved indentation
Dominant language
Java
Stars
9.6k
Forks
4.2k
Avg merge
22h 23m
Merged PRs (30d)
232

Description

The following is correctly formatted (in my opinion):
```
{ cs } » javac Temp.java
{ cs } » cat Temp.java
import java.util.List;

/**
* Test
*/
public class Temp {
/**
* test
*
* @param strings test
*/
private void test(final List strings) {
final StringBuilder sb1 = new StringBuilder();
final StringBuilder sb2 = new StringBuilder();
strings.add(
2,
sb1.append("a")
.append("b") //violation
.append(sb2 //violation
.append("a2") //violation
.append("b2") //violation
.toString()) //violation
.toString()); //violation
}
}

{ cs } » cat config.xml













{ cs } » java -jar checkstyle-7.5.1-all.jar -c config.xml Temp.java
Starting audit...
[ERROR] ...\Temp.java:18: '.' have incorrect indentation level 16, expected level should be 12. [Indentation]
[ERROR] ...\Temp.java:19: '.' have incorrect indentation level 16, expected level should be 12. [Indentation]
[ERROR] ...\Temp.java:20: '.' have incorrect indentation level 20, expected level should be 12. [Indentation]
[ERROR] ...\Temp.java:21: '.' have incorrect indentation level 20, expected level should be 12. [Indentation]
[ERROR] ...\Temp.java:22: '.' have incorrect indentation level 20, expected level should be 12. [Indentation]
[ERROR] ...\Temp.java:23: '.' have incorrect indentation level 16, expected level should be 12. [Indentation]
Audit done.
Checkstyle ends with 6 errors.
```

Expected: no errors

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.