xref: /aosp_15_r20/prebuilts/checkstyle/default-treewalker-checks.xml (revision 387726c4b5c67c6b48512fa4a28a3b8997d21b0d)
1*387726c4SAndroid Build Coastguard Worker<?xml version="1.0" encoding="UTF-8"?>
2*387726c4SAndroid Build Coastguard Worker<!--
3*387726c4SAndroid Build Coastguard Worker  ~ Copyright (C) 2016 The Android Open Source Project
4*387726c4SAndroid Build Coastguard Worker  ~
5*387726c4SAndroid Build Coastguard Worker  ~ Licensed under the Apache License, Version 2.0 (the "License");
6*387726c4SAndroid Build Coastguard Worker  ~ you may not use this file except in compliance with the License.
7*387726c4SAndroid Build Coastguard Worker  ~ You may obtain a copy of the License at
8*387726c4SAndroid Build Coastguard Worker  ~
9*387726c4SAndroid Build Coastguard Worker  ~      http://www.apache.org/licenses/LICENSE-2.0
10*387726c4SAndroid Build Coastguard Worker  ~
11*387726c4SAndroid Build Coastguard Worker  ~ Unless required by applicable law or agreed to in writing, software
12*387726c4SAndroid Build Coastguard Worker  ~ distributed under the License is distributed on an "AS IS" BASIS,
13*387726c4SAndroid Build Coastguard Worker  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*387726c4SAndroid Build Coastguard Worker  ~ See the License for the specific language governing permissions and
15*387726c4SAndroid Build Coastguard Worker  ~ limitations under the License.
16*387726c4SAndroid Build Coastguard Worker-->
17*387726c4SAndroid Build Coastguard Worker<module name="AvoidStarImport">
18*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
19*387726c4SAndroid Build Coastguard Worker  <property name="excludes" value="org.junit.Assert,org.mockito.Mockito,org.mockito.MockitoAnnotations,org.hamcrest.Matchers"/>
20*387726c4SAndroid Build Coastguard Worker</module>
21*387726c4SAndroid Build Coastguard Worker<module name="IllegalCatch">
22*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="info"/>
23*387726c4SAndroid Build Coastguard Worker</module>
24*387726c4SAndroid Build Coastguard Worker<module name="RedundantImport">
25*387726c4SAndroid Build Coastguard Worker  <message key="import.redundant" value="Redundant import: {0}. Use Ctrl+Shift+O (Eclipse) or Ctrl+Alt+O (Intellij) to sort imports"/>
26*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
27*387726c4SAndroid Build Coastguard Worker</module>
28*387726c4SAndroid Build Coastguard Worker<module name="UnusedImports">
29*387726c4SAndroid Build Coastguard Worker  <message key="import.unused" value="Unused import: {0}. Use Ctrl+Shift+O (Eclipse) or Ctrl+Alt+O (Intellij) to sort imports"/>
30*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
31*387726c4SAndroid Build Coastguard Worker  <property name="processJavadoc" value="true"/>
32*387726c4SAndroid Build Coastguard Worker</module>
33*387726c4SAndroid Build Coastguard Worker<module name="PackageName">
34*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
35*387726c4SAndroid Build Coastguard Worker  <property name="format" value="^[a-z]+(\.[a-z][a-z0-9_]{1,})*$"/>
36*387726c4SAndroid Build Coastguard Worker</module>
37*387726c4SAndroid Build Coastguard Worker<module name="SimplifyBooleanExpression">
38*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
39*387726c4SAndroid Build Coastguard Worker</module>
40*387726c4SAndroid Build Coastguard Worker<module name="SimplifyBooleanReturn">
41*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
42*387726c4SAndroid Build Coastguard Worker</module>
43*387726c4SAndroid Build Coastguard Worker<module name="TypeName">
44*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
45*387726c4SAndroid Build Coastguard Worker  <property name="format" value="^[A-Z][a-zA-Z0-9_]*$"/>
46*387726c4SAndroid Build Coastguard Worker</module>
47*387726c4SAndroid Build Coastguard Worker<module name="ConstantName">
48*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
49*387726c4SAndroid Build Coastguard Worker  <property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*)|(s[A-Z][a-zA-Z0-9]*)$"/>
50*387726c4SAndroid Build Coastguard Worker  <message key="name.invalidPattern" value="Static final field names must either be all caps (e.g. int HEIGHT_PX) for 'true' constants, or start with s (e.g. AtomicInteger sNextId or Runnable sSuspendTask) for fields with mutable state or that don't 'feel' like constants."/>
51*387726c4SAndroid Build Coastguard Worker</module>
52*387726c4SAndroid Build Coastguard Worker<!-- Non-public, non-static field names start with m. -->
53*387726c4SAndroid Build Coastguard Worker<module name="MemberName">
54*387726c4SAndroid Build Coastguard Worker    <property name="severity" value="error"/>
55*387726c4SAndroid Build Coastguard Worker    <property name="format" value="^m[A-Z0-9][a-zA-Z0-9]*$"/>
56*387726c4SAndroid Build Coastguard Worker    <property name="applyToPublic" value="false"/>
57*387726c4SAndroid Build Coastguard Worker    <message key="name.invalidPattern" value="Non-public, non-static field names start with m and are camel-cased. (e.g. mSize)"/>
58*387726c4SAndroid Build Coastguard Worker</module>
59*387726c4SAndroid Build Coastguard Worker<!-- Static field names start with s. -->
60*387726c4SAndroid Build Coastguard Worker<module name="StaticVariableName">
61*387726c4SAndroid Build Coastguard Worker    <property name="severity" value="error"/>
62*387726c4SAndroid Build Coastguard Worker    <property name="format" value="^s[A-Z0-9][a-zA-Z0-9]*$"/>
63*387726c4SAndroid Build Coastguard Worker    <property name="applyToPublic" value="false"/>
64*387726c4SAndroid Build Coastguard Worker    <message key="name.invalidPattern" value="Static field names start with s and are camel-cased. (e.g. sFooBar)"/>
65*387726c4SAndroid Build Coastguard Worker</module>
66*387726c4SAndroid Build Coastguard Worker<module name="MethodName">
67*387726c4SAndroid Build Coastguard Worker    <property name="severity" value="error"/>
68*387726c4SAndroid Build Coastguard Worker    <property name="format" value="^[a-z][a-zA-Z0-9_]*(\$ravenwood)?$"/>
69*387726c4SAndroid Build Coastguard Worker    <message key="name.invalidPattern" value="Method names should start with a lower case letter (e.g. getWidth())"/>
70*387726c4SAndroid Build Coastguard Worker</module>
71*387726c4SAndroid Build Coastguard Worker<module name="ParameterName">
72*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
73*387726c4SAndroid Build Coastguard Worker</module>
74*387726c4SAndroid Build Coastguard Worker<module name="LocalFinalVariableName">
75*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
76*387726c4SAndroid Build Coastguard Worker  <property name="format" value="^m|s|((([ms][a-z0-9])|([a-ln-rt-z]))[a-zA-Z0-9]*)$"/>
77*387726c4SAndroid Build Coastguard Worker  <message key="name.invalidPattern" value="Local variables should be camel-cased (e.g. int minWidth = 4)."/>
78*387726c4SAndroid Build Coastguard Worker</module>
79*387726c4SAndroid Build Coastguard Worker<module name="LocalVariableName">
80*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
81*387726c4SAndroid Build Coastguard Worker  <property name="format" value="^m|s|((([ms][a-z0-9])|([a-ln-rt-z]))[a-zA-Z0-9]*)$"/>
82*387726c4SAndroid Build Coastguard Worker  <message key="name.invalidPattern" value="Local variables should be camel-cased (e.g. int minWidth = 4)."/>
83*387726c4SAndroid Build Coastguard Worker</module>
84*387726c4SAndroid Build Coastguard Worker<module name="LeftCurly">
85*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
86*387726c4SAndroid Build Coastguard Worker</module>
87*387726c4SAndroid Build Coastguard Worker<module name="RightCurly">
88*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
89*387726c4SAndroid Build Coastguard Worker</module>
90*387726c4SAndroid Build Coastguard Worker<module name="NeedBraces">
91*387726c4SAndroid Build Coastguard Worker  <message key="needBraces" value="if, for, while, and do require curly braces unless they are single-line statements."/>
92*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
93*387726c4SAndroid Build Coastguard Worker  <property name="tokens" value="LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, LITERAL_IF"/>
94*387726c4SAndroid Build Coastguard Worker  <property name="allowSingleLineStatement" value="true"/>
95*387726c4SAndroid Build Coastguard Worker</module>
96*387726c4SAndroid Build Coastguard Worker<module name="EmptyBlock">
97*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
98*387726c4SAndroid Build Coastguard Worker  <property name="option" value="text"/>
99*387726c4SAndroid Build Coastguard Worker  <metadata name="altname" value="EmptyCatchBlock"/>
100*387726c4SAndroid Build Coastguard Worker</module>
101*387726c4SAndroid Build Coastguard Worker<module name="UpperEll">
102*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
103*387726c4SAndroid Build Coastguard Worker</module>
104*387726c4SAndroid Build Coastguard Worker<module name="FallThrough">
105*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
106*387726c4SAndroid Build Coastguard Worker  <property name="reliefPattern" value=".*"/>
107*387726c4SAndroid Build Coastguard Worker</module>
108*387726c4SAndroid Build Coastguard Worker<module name="ModifierOrder">
109*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
110*387726c4SAndroid Build Coastguard Worker</module>
111*387726c4SAndroid Build Coastguard Worker<module name="WhitespaceAround">
112*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
113*387726c4SAndroid Build Coastguard Worker  <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE, LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, TYPE_EXTENSION_AND" />
114*387726c4SAndroid Build Coastguard Worker  <property name="allowEmptyConstructors" value="true"/>
115*387726c4SAndroid Build Coastguard Worker  <property name="allowEmptyLambdas" value="true"/>
116*387726c4SAndroid Build Coastguard Worker  <property name="allowEmptyMethods" value="true"/>
117*387726c4SAndroid Build Coastguard Worker</module>
118*387726c4SAndroid Build Coastguard Worker<module name="WhitespaceAfter">
119*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
120*387726c4SAndroid Build Coastguard Worker  <property name="tokens" value="COMMA, SEMI, TYPECAST"/>
121*387726c4SAndroid Build Coastguard Worker</module>
122*387726c4SAndroid Build Coastguard Worker<module name="NoWhitespaceAfter">
123*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
124*387726c4SAndroid Build Coastguard Worker  <property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS"/>
125*387726c4SAndroid Build Coastguard Worker</module>
126*387726c4SAndroid Build Coastguard Worker<module name="NoWhitespaceBefore">
127*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
128*387726c4SAndroid Build Coastguard Worker  <property name="allowLineBreaks" value="true"/>
129*387726c4SAndroid Build Coastguard Worker  <property name="tokens" value="SEMI, DOT, POST_DEC, POST_INC"/>
130*387726c4SAndroid Build Coastguard Worker</module>
131*387726c4SAndroid Build Coastguard Worker<module name="GenericWhitespace">
132*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
133*387726c4SAndroid Build Coastguard Worker  <message key="ws.followed"
134*387726c4SAndroid Build Coastguard Worker   value="GenericWhitespace ''{0}'' is followed by whitespace."/>
135*387726c4SAndroid Build Coastguard Worker   <message key="ws.preceded"
136*387726c4SAndroid Build Coastguard Worker   value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
137*387726c4SAndroid Build Coastguard Worker   <message key="ws.illegalFollow"
138*387726c4SAndroid Build Coastguard Worker   value="GenericWhitespace ''{0}'' should followed by whitespace."/>
139*387726c4SAndroid Build Coastguard Worker   <message key="ws.notPreceded"
140*387726c4SAndroid Build Coastguard Worker   value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
141*387726c4SAndroid Build Coastguard Worker</module>
142*387726c4SAndroid Build Coastguard Worker<module name="EmptyStatement">
143*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
144*387726c4SAndroid Build Coastguard Worker</module>
145*387726c4SAndroid Build Coastguard Worker<module name="NoFinalizer">
146*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="info"/>
147*387726c4SAndroid Build Coastguard Worker</module>
148*387726c4SAndroid Build Coastguard Worker<module name="ParenPad">
149*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
150*387726c4SAndroid Build Coastguard Worker</module>
151*387726c4SAndroid Build Coastguard Worker<module name="MethodParamPad">
152*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
153*387726c4SAndroid Build Coastguard Worker</module>
154*387726c4SAndroid Build Coastguard Worker<module name="ImportOrder">
155*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
156*387726c4SAndroid Build Coastguard Worker  <message key="import.ordering" value="Wrong order for {0} import. Use Ctrl+Shift+O (Eclipse) or Ctrl+Alt+O (Intellij) to sort imports. https://source.android.com/setup/code-style#order-import-statements"/>
157*387726c4SAndroid Build Coastguard Worker  <property name="groups" value="android, androidx, com.android, dalvik, com, dagger, de, gov, io, junit, junitparams, libcore, net, kotlin, kotlinx, org, perfetto, vendor, java, javax"/>
158*387726c4SAndroid Build Coastguard Worker  <property name="ordered" value="true"/>
159*387726c4SAndroid Build Coastguard Worker  <property name="option" value="top"/>
160*387726c4SAndroid Build Coastguard Worker  <property name="separated" value="true"/>
161*387726c4SAndroid Build Coastguard Worker  <property name="separatedStaticGroups" value="true"/>
162*387726c4SAndroid Build Coastguard Worker  <property name="staticGroups" value="android, androidx, com.android, dalvik, com, dagger, de, gov, io, junit, junitparams, libcore, net, kotlin, kotlinx, org, perfetto, java, javax"/>
163*387726c4SAndroid Build Coastguard Worker</module>
164*387726c4SAndroid Build Coastguard Worker<module name="Indentation">
165*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
166*387726c4SAndroid Build Coastguard Worker  <property name="basicOffset" value="4"/>
167*387726c4SAndroid Build Coastguard Worker  <property name="throwsIndent" value="8"/>
168*387726c4SAndroid Build Coastguard Worker  <property name="lineWrappingIndentation" value="8"/>
169*387726c4SAndroid Build Coastguard Worker</module>
170*387726c4SAndroid Build Coastguard Worker<module name="OperatorWrap">
171*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
172*387726c4SAndroid Build Coastguard Worker  <property name="option" value="NL" />
173*387726c4SAndroid Build Coastguard Worker  <property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR " />
174*387726c4SAndroid Build Coastguard Worker</module>
175*387726c4SAndroid Build Coastguard Worker<module name="OperatorWrap">
176*387726c4SAndroid Build Coastguard Worker <property name="severity" value="error"/>
177*387726c4SAndroid Build Coastguard Worker <property name="option" value="eol"/>
178*387726c4SAndroid Build Coastguard Worker <property name="tokens" value="ASSIGN"/>
179*387726c4SAndroid Build Coastguard Worker</module>
180*387726c4SAndroid Build Coastguard Worker<module name="SeparatorWrap">
181*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
182*387726c4SAndroid Build Coastguard Worker  <property name="tokens" value="DOT"/>
183*387726c4SAndroid Build Coastguard Worker  <property name="option" value="nl"/>
184*387726c4SAndroid Build Coastguard Worker</module>
185*387726c4SAndroid Build Coastguard Worker<module name="SeparatorWrap">
186*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
187*387726c4SAndroid Build Coastguard Worker  <property name="tokens" value="COMMA"/>
188*387726c4SAndroid Build Coastguard Worker  <property name="option" value="EOL"/>
189*387726c4SAndroid Build Coastguard Worker</module>
190*387726c4SAndroid Build Coastguard Worker<module name="MissingDeprecated">
191*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
192*387726c4SAndroid Build Coastguard Worker</module>
193*387726c4SAndroid Build Coastguard Worker<module name="MissingOverride">
194*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
195*387726c4SAndroid Build Coastguard Worker</module>
196*387726c4SAndroid Build Coastguard Worker<module name="OneTopLevelClass">
197*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
198*387726c4SAndroid Build Coastguard Worker</module>
199*387726c4SAndroid Build Coastguard Worker<module name="StringLiteralEquality">
200*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
201*387726c4SAndroid Build Coastguard Worker</module>
202*387726c4SAndroid Build Coastguard Worker<module name="ArrayTypeStyle">
203*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
204*387726c4SAndroid Build Coastguard Worker</module>
205*387726c4SAndroid Build Coastguard Worker<module name="RedundantModifier">
206*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
207*387726c4SAndroid Build Coastguard Worker</module>
208*387726c4SAndroid Build Coastguard Worker<module name="OuterTypeFilename">
209*387726c4SAndroid Build Coastguard Worker  <property name="severity" value="error"/>
210*387726c4SAndroid Build Coastguard Worker</module>
211*387726c4SAndroid Build Coastguard Worker<module name="SuppressionCommentFilter">
212*387726c4SAndroid Build Coastguard Worker  <property name="offCommentFormat" value="CHECKSTYLE:OFF IndentationCheck"/>
213*387726c4SAndroid Build Coastguard Worker  <property name="onCommentFormat" value="CHECKSTYLE:ON IndentationCheck"/>
214*387726c4SAndroid Build Coastguard Worker  <property name="checkFormat" value="IndentationCheck"/>
215*387726c4SAndroid Build Coastguard Worker</module>
216*387726c4SAndroid Build Coastguard Worker<module name="SuppressionCommentFilter">
217*387726c4SAndroid Build Coastguard Worker  <property name="offCommentFormat" value="CHECKSTYLE:OFF Generated code"/>
218*387726c4SAndroid Build Coastguard Worker  <property name="onCommentFormat" value="CHECKSTYLE:ON Generated code"/>
219*387726c4SAndroid Build Coastguard Worker</module>
220