forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchromium-style-5.0.xml
280 lines (279 loc) · 17 KB
/
chromium-style-5.0.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!--
See installation instructions: https://sites.google.com/a/chromium.org/dev/developers/checkstyle
-->
<module name="Checker">
<property name="severity" value="warning"/>
<property name="charset" value="UTF-8"/>
<module name="SuppressionFilter">
<property name="file" value="tools/android/checkstyle/suppressions.xml"/>
</module>
<module name="SuppressWarningsFilter"/>
<module name="TreeWalker">
<module name="SuppressWarningsHolder"/>
<module name="ArrayTypeStyle"/>
<module name="AvoidDoubleBraceInitialization"/>
<module name="DefaultComesLast"/>
<module name="EmptyStatement"/>
<module name="InnerAssignment"/>
<module name="OneStatementPerLine"/>
<module name="StringLiteralEquality"/>
<module name="UnusedLocalVariable"/>
<module name="AvoidStarImport">
<property name="severity" value="error"/>
</module>
<module name="IllegalCatch">
<property name="severity" value="info"/>
</module>
<module name="ModifierOrder">
<message key="mod.order" value=""{0}" modifier out of order with the JLS suggestions. The correct order: public protected private abstract default static final transient volatile synchronized native strictfp. See https://crbug.com/1003711 for details."/>
<property name="severity" value="error"/>
</module>
<module name="RedundantImport">
<message key="import.redundant" value="Redundant import: {0}."/>
<property name="severity" value="error"/>
</module>
<module name="UnusedImports">
<message key="import.unused" value="Unused import: {0}."/>
<property name="severity" value="error"/>
<property name="processJavadoc" value="true"/>
</module>
<module name="JavadocType">
<property name="severity" value="warning"/>
<property name="tokens" value="INTERFACE_DEF, CLASS_DEF"/>
<property name="scope" value="public"/>
<property name="allowedAnnotations" value="NativeMethods"/>
<message key="javadoc.missing" value="Public classes and interfaces require JavaDoc comments."/>
</module>
<module name="JavadocMethod">
<property name="severity" value="info"/>
<property name="accessModifiers" value="public"/>
<property name="allowMissingParamTags" value="true"/>
<property name="allowMissingReturnTag" value="true"/>
</module>
<module name="PackageName">
<property name="severity" value="error"/>
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9_]{1,})*$"/>
</module>
<module name="SimplifyBooleanExpression">
<property name="severity" value="error"/>
</module>
<module name="SimplifyBooleanReturn">
<property name="severity" value="error"/>
</module>
<module name="TypeName">
<property name="severity" value="error"/>
</module>
<module name="ConstantName">
<property name="severity" value="error"/>
<property name="format" value="^([A-Z][A-Z0-9]*(_[A-Z0-9]+)*)|(s[A-Z][a-zA-Z0-9]*)$"/>
<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."/>
</module>
<!-- Non-public, non-static field names start with m. -->
<module name="MemberName">
<property name="severity" value="error"/>
<property name="format" value="^m[A-Z][a-zA-Z0-9]*$"/>
<property name="applyToPublic" value="false"/>
<message key="name.invalidPattern" value="Non-public, non-static field names start with m."/>
</module>
<!-- Static field names start with s. -->
<module name="StaticVariableName">
<property name="severity" value="error"/>
<property name="format" value="^s[A-Z][a-zA-Z0-9]*$"/>
<property name="applyToPublic" value="false"/>
<message key="name.invalidPattern" value="Static field names start with s."/>
</module>
<module name="MethodName">
<property name="id" value="MethodNameCheck"/>
<property name="severity" value="error"/>
<property name="format" value="^(([a-z][a-zA-Z0-9_]*)|(__constructor__))$"/>
<message key="name.invalidPattern" value="Method names should start with a lower case letter (e.g. getWidth())"/>
</module>
<module name="ParameterName">
<property name="format" value="^(unused_)?[a-z][a-zA-Z0-9]*$"/>
<property name="severity" value="error"/>
</module>
<module name="LocalFinalVariableName">
<property name="severity" value="error"/>
<property name="format" value="^m|s|((([ms][a-z0-9])|([a-ln-rt-z]))[a-zA-Z0-9]*)$"/>
<message key="name.invalidPattern" value="Local variables should be camel-cased (e.g. int minWidth = 4)."/>
</module>
<module name="LocalVariableName">
<property name="severity" value="error"/>
<property name="format" value="^m|s|((([ms][a-z0-9])|([a-ln-rt-z]))[a-zA-Z0-9]*)$"/>
<message key="name.invalidPattern" value="Local variables should be camel-cased (e.g. int minWidth = 4)."/>
</module>
<module name="AbbreviationAsWordInName">
<!-- https://source.android.com/docs/setup/contribute/code-style#treat-acronyms-as-words -->
<property name="severity" value="warning"/>
<property name="allowedAbbreviationLength" value="0"/>
<!-- Fixing/changing GURL is not happening. X/Y/Z variable names
implicitly have meaning without any trailing lower case letters, and often
must be in the middle of an associated method name, especially when the
name needs ForTesting suffix. J allows JUnit which we want to exactly
match and is defined externally. -->
<property name="allowedAbbreviations" value="GURL,X,Y,Z,J"/>
</module>
<module name="FallThrough">
<property name="severity" value="error"/>
<property name="reliefPattern" value=".*"/>
</module>
<module name="NoFinalizer">
<property name="severity" value="info"/>
</module>
<module name="NeedBraces">
<property name="severity" value="warning"/>
<property name="allowSingleLineStatement" value="true"/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="StringBufferCheck"/>
<property name="severity" value="error"/>
<property name="format" value="StringBuffer"/>
<property name="ignoreComments" value="true"/>
<property name="message" value="Avoid StringBuffer; use StringBuilder instead, which is faster (it's not thread-safe, but this is almost never needed)"/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="AlertDialogCheck"/>
<property name="severity" value="warning"/>
<property name="format" value="android\.app\.AlertDialog"/>
<property name="ignoreComments" value="true"/>
<property name="message" value="Avoid android.app.AlertDialog; if possible, use android.support.v7.app.AlertDialog instead, which has a Material look on all devices. (Some parts of the codebase can’t depend on the support library, in which case android.app.AlertDialog is the only option)"/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="UseSharedPreferencesManagerFromChromeCheck"/>
<property name="severity" value="warning"/>
<property name="format" value="(getAppSharedPreferences|getDefaultSharedPreferences)"/>
<property name="ignoreComments" value="true"/>
<property name="message" value="Use SharedPreferencesManager instead to access app-wide SharedPreferences from //src/chrome."/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="DefaultSharedPreferencesCheck"/>
<property name="severity" value="error"/>
<property name="format" value="getDefaultSharedPreferences"/>
<property name="ignoreComments" value="true"/>
<property name="message" value="Use ContextUtils.getAppSharedPreferences() instead to access app-wide SharedPreferences."/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="ConcurrentHashMapCheck"/>
<property name="severity" value="error"/>
<property name="format" value="ConcurrentHashMap"/>
<property name="ignoreComments" value="true"/>
<property name="message" value="ConcurrentHashMap has a bug on some Android versions. Use Collections.synchronizedMap() instead (crbug.com/905903)."/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="StrictModeContextIgnoredCheck"/>
<property name="severity" value="error"/>
<property name="format" value="try .*StrictModeContext (?!ignored).*="/>
<property name="ignoreComments" value="true"/>
<property name="message" value="Please name the StrictModeContext variable "ignored" (crbug.com/767058#c4)."/>
</module>
<module name="RegexpSinglelineJava">
<!-- Tests are also allowed to use System.exit if need be, please add dirs to tools/android/checkstyle/suppressions.xml -->
<property name="id" value="SystemExitCheck"/>
<property name="severity" value="error"/>
<property name="format" value="System\.exit\("/>
<property name="ignoreComments" value="true"/>
<property name="message" value="Throw an exception instead of calling System#exit (crbug.com/1000651)."/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="AndroidButtonWidgetCheck"/>
<property name="severity" value="warning"/>
<property name="format" value="extends\ Button|extends\ AppCompatButton"/>
<property name="ignoreComments" value="true"/>
<property name="message" value="Use org.chromium.ui.widget.ButtonCompat instead of Button and AppCompatButton if possible; ButtonCompat is a Material-styled button with a customizable background color. On L devices, this is a true Material button. On earlier devices, the button is similar but lacks ripples and a shadow. (crbug.com/775198)"/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="SetTextColorAndSetTextSizeCheck"/>
<property name="severity" value="warning"/>
<property name="format" value="\.setTextColor\(|\.setTextSize\("/>
<property name="ignoreComments" value="true"/>
<property name="message" value="If possible, please use #setTextAppearance to set one of the pre-defined text appearance styles in src/ui/android/java/res/values-v17/styles.xml, instead of using #setTextColor or #setTextSize. This will ensure that your programmatically set text styles stay in-sync with text styles used in the rest of Chrome. (crbug.com/775198)"/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="ActivityScenarioLaunch"/>
<property name="severity" value="warning"/>
<property name="format" value="ActivityScenario\.launch"/>
<property name="ignoreComments" value="true"/>
<property name="message" value="Launching an ActivityScenario manually is error prone for any test run in a batch. Failing to #close will cause the Activity to leak into the next test. Consider replacing with ActivityScenarioRule. (https://crbug.com/1338271)"/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="GuavaOptional"/>
<property name="severity" value="warning"/>
<property name="format" value="import\ com.google.common.base.Optional;"/>
<property name="ignoreComments" value="true"/>
<property name="message" value="Use java.util.Optional instead of com.google.common.base.Optional unless required to interact with external libraries."/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="CollectionSubclass"/>
<property name="severity" value="warning"/>
<!-- E.g., matches "new HashSet<>() {" -->
<!-- Careful to not match "for (String s : new HashSet<>(input)) {" -->
<property name="format" value="new \w+(?:List|Set|Map)\b[^()]*\([^()]*\)[^()]*\{"/>
<property name="ignoreComments" value="true"/>
<property name="message" value="Subclassing collections is uncommon. If you are not doing so, please ignore. If you are subclassing in order to call add()/put(), use List.of() / Set.of() / Map.of() instead, or use multiple statements."/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="AccessibilityManagerUsage"/>
<property name="severity" value="warning"/>
<property name="format" value="android\.view\.accessibility\.AccessibilityManager"/>
<property name="ignoreComments" value="true"/>
<property name="message" value="Use org.chromium.ui.accessibility.AccessibilityState instead of AccessibilityManager. For more information, contact //ui/accessibility/OWNERS."/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="FullscreenDialogs"/>
<property name="severity" value="warning"/>
<property name="format" value="ThemeOverlay\_BrowserUI\_Fullscreen"/>
<property name="message" value="Fullscreen AlertDialogs must use FullscreenAlertDialog and fullscreen Dialogs must use ChromeDialog. Not doing this will break automotive devices. (This check is triggered by the presence of ThemeOverlay_BrowserUI_Fullscreen and does not know if you are already using the correct class)"/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="InclusiveLanguageCheck"/>
<property name="severity" value="warning"/>
<property name="format" value="([dD]ummy)|([sS]anity)|([bB]lind)"/>
<property name="message" value="

Please use inclusive language where possible.

Instead of 'dummy', use a term such as placeholder or empty (e.g. PlaceholderImpl, not DummyImpl).
Instead of 'sanity', use a term such as 'confidence' (e.g. confidence check, not sanity check).
Instead of 'blind', use a term such as unaware (e.g. being unaware of, not being blind to. unconfirmed change, not blind change).

For more info see: https://developers.google.com/style/word-list
"/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="SettingsFragmentCheck"/>
<property name="severity" value="warning"/>
<property name="format" value="PreferenceFragment.*\ extends\ (PreferenceFragment|ChromeBaseSettingsFragment)"/>
<property name="message" value="Top level settings fragment should be named with suffix 'SettingsFragment' or 'Settings'. See //components/browser_ui/settings/README."/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="ParamComments"/>
<property name="severity" value="warning"/>
<property name="format" value="/\*\*? ?\w+ ?\*/,|, /\*\*? ?\w+ ?\*/"/>
<property name="message" value="Parameter comments should use the ErrorProne-aware syntax: /* paramName= */."/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="RemoveObserverMethodReference"/>
<property name="severity" value="warning"/>
<property name="format" value="remove[A-Z][a-zA-Z]*\([a-zA-Z]+::"/>
<property name="message" value="Each method reference creates a new instance. The specific object given to the addObserver-like-method needs to be remembered and given to the removeObserver-like-method."/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="MockitoInitMocks"/>
<property name="severity" value="warning"/>
<property name="format" value="MockitoAnnotations.initMocks"/>
<property name="message" value="Prefer to use MockitoJUnit.Rule for consistency unless timing of when exactly mocks are initialized is required."/>
</module>
<module name="RegexpSinglelineJava">
<property name="id" value="SetDecorFitsSystemWindowsCheck"/>
<property name="severity" value="warning"/>
<property name="format" value="[Ww]indow(Compat)?.setDecorFitsSystemWindows"/>
<property name="ignoreComments" value="true"/>
<property name="message" value="setDecorFitsSystemWindows will change the window flag at activity level, and requires coordination. Use org.chromium.browser_ui.edge_to_edge.EdgeToEdgeStateProvider if possible. (crbug.com/41492646)"/>
</module>
</module>
<module name="RegexpMultiline">
<property name="id" value="VisibleForTestingForTesting"/>
<property name="severity" value="warning"/>
<property name="format" value="@VisibleForTesting.*\n.*ForTests?(ing)\("/>
<property name="message" value="There is no need to add @VisibleForTesting to test-only methods (those with "ForTesting" suffix)."/>
</module>
<module name="RegexpMultiline">
<property name="id" value="ContextGetString"/>
<property name="severity" value="warning"/>
<property name="format" value="ontext\(?\)?\s*\.getResources\(\)\s*\.getString\("/>
<property name="message" value="Use Context.getString() rather than Context.getResources().getString()."/>
</module>
</module>