public class Test {
public class C1{}
public
class C2{} // violation, expected 6
public
static class C3{} // violation, expected 6
public
static class C4{} // this is a violation too, can't make check happy, expects 2
public
static // violation, expected 6
strictfp class C5{} // violation, expected 6
public
static // violation, can't make check happy, expects 2
strictfp class C6{} // violation, can't make check happy, expects 2
public
@X // violation, expected 6
static class C7{} // violation, expected 6
public
@X // violation, expected 6
@Y // violation, expected 6
static class C8{} // violation, expected 6
public
@X // violation, can't make check happy, expects 2
@Y // violation, can't make check happy, expects 2
static class C9{} // violation, can't make check happy, expects 2
@interface X{}
@interface Y{}
@interface Z{}
}
➜ src 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">
<property name="charset" value="UTF-8"/>
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/>
<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>
➜ src java -jar checkstyle-10.13.0-all.jar -c config.xml Test.java
Starting audit...
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:6:3: 'class' has incorrect indentation level 2, expected level should be 6. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:9:3: 'static' has incorrect indentation level 2, expected level should be 6. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:12:5: 'class def modifier' has incorrect indentation level 4, expected level should be 2. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:15:3: 'static' has incorrect indentation level 2, expected level should be 6. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:16:3: 'strictfp' has incorrect indentation level 2, expected level should be 6. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:19:7: 'class def modifier' has incorrect indentation level 6, expected level should be 2. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:20:7: 'class def modifier' has incorrect indentation level 6, expected level should be 2. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:23:3: '@' has incorrect indentation level 2, expected level should be 6. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:24:3: 'static' has incorrect indentation level 2, expected level should be 6. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:27:3: '@' has incorrect indentation level 2, expected level should be 6. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:28:3: '@' has incorrect indentation level 2, expected level should be 6. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:29:3: 'static' has incorrect indentation level 2, expected level should be 6. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:32:7: 'class def modifier' has incorrect indentation level 6, expected level should be 2. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:33:7: 'class def modifier' has incorrect indentation level 6, expected level should be 2. [Indentation]
[WARN] /home/nick/IdeaProjects/tester/src/Test.java:34:7: 'class def modifier' has incorrect indentation level 6, expected level should be 2. [Indentation]
Audit done.