/
IndentationCheck.xml
84 lines (84 loc) · 4 KB
/
IndentationCheck.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?xml version="1.0" encoding="UTF-8"?>
<checkstyle-metadata>
<module>
<check fully-qualified-name="com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck"
name="Indentation"
parent="com.puppycrawl.tools.checkstyle.TreeWalker">
<description><p>
Checks correct indentation of Java code.
</p>
<p>
The idea behind this is that while
pretty printers are sometimes convenient for bulk reformats of
legacy code, they often either aren't configurable enough or
just can't anticipate how format should be done. Sometimes this is
personal preference, other times it is practical experience. In any
case, this check should just ensure that a minimal set of indentation
rules is followed.
</p>
<p>
Basic offset indentation is used for indentation inside code blocks.
For any lines that span more than 1, line wrapping indentation is used for those lines
after the first. Brace adjustment, case, and throws indentations are all used only if
those specific identifiers start the line. If, for example, a brace is used in the
middle of the line, its indentation will not take effect. All indentations have an
accumulative/recursive effect when they are triggered. If during a line wrapping, another
code block is found and it doesn't end on that same line, then the subsequent lines
afterwards, in that new code block, are increased on top of the line wrap and any
indentations above it.
</p>
<p>
Example:
</p>
<pre>
if ((condition1 &amp;&amp; condition2)
|| (condition3 &amp;&amp; condition4) // line wrap with bigger indentation
||!(condition5 &amp;&amp; condition6)) { // line wrap with bigger indentation
field.doSomething() // basic offset
.doSomething() // line wrap
.doSomething( c -&gt; { // line wrap
return c.doSome(); // basic offset
});
}
</pre></description>
<properties>
<property default-value="4" name="basicOffset" type="int">
<description>Specify how far new indentation level should be
indented when on the next line.</description>
</property>
<property default-value="0" name="braceAdjustment" type="int">
<description>Specify how far a braces should be indented
when on the next line.</description>
</property>
<property default-value="4" name="caseIndent" type="int">
<description>Specify how far a case label should be indented
when on next line.</description>
</property>
<property default-value="4" name="throwsIndent" type="int">
<description>Specify how far a throws clause should be
indented when on next line.</description>
</property>
<property default-value="4" name="arrayInitIndent" type="int">
<description>Specify how far an array initialisation
should be indented when on next line.</description>
</property>
<property default-value="4" name="lineWrappingIndentation" type="int">
<description>Specify how far continuation line
should be indented when line-wrapping is present.</description>
</property>
<property default-value="false" name="forceStrictCondition" type="boolean">
<description>Force strict indent level in line
wrapping case. If value is true, line wrap indent have to be same as
lineWrappingIndentation parameter. If value is false, line wrap indent
could be bigger on any value user would like.</description>
</property>
</properties>
<message-keys>
<message-key key="indentation.child.error"/>
<message-key key="indentation.child.error.multi"/>
<message-key key="indentation.error"/>
<message-key key="indentation.error.multi"/>
</message-keys>
</check>
</module>
</checkstyle-metadata>