[SPARK-7721][PYTHON][TESTS] Adds PySpark coverage generation script
[spark.git] / scalastyle-config.xml
1 <!--
2 ~ Licensed to the Apache Software Foundation (ASF) under one or more
3 ~ contributor license agreements. See the NOTICE file distributed with
4 ~ this work for additional information regarding copyright ownership.
5 ~ The ASF licenses this file to You under the Apache License, Version 2.0
6 ~ (the "License"); you may not use this file except in compliance with
7 ~ the License. You may obtain a copy of the License at
8 ~
9 ~ http://www.apache.org/licenses/LICENSE-2.0
10 ~
11 ~ Unless required by applicable law or agreed to in writing, software
12 ~ distributed under the License is distributed on an "AS IS" BASIS,
13 ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ~ See the License for the specific language governing permissions and
15 ~ limitations under the License.
16 -->
17 <!--
18
19 If you wish to turn off checking for a section of code, you can put a comment in the source
20 before and after the section, with the following syntax:
21
22 // scalastyle:off
23 ... // stuff that breaks the styles
24 // scalastyle:on
25
26 You can also disable only one rule, by specifying its rule id, as specified in:
27 http://www.scalastyle.org/rules-0.7.0.html
28
29 // scalastyle:off no.finalize
30 override def finalize(): Unit = ...
31 // scalastyle:on no.finalize
32
33 This file is divided into 3 sections:
34 (1) rules that we enforce.
35 (2) rules that we would like to enforce, but haven't cleaned up the codebase to turn on yet
36 (or we need to make the scalastyle rule more configurable).
37 (3) rules that we don't want to enforce.
38 -->
39
40 <scalastyle>
41 <name>Scalastyle standard configuration</name>
42
43 <!-- ================================================================================ -->
44 <!-- rules we enforce -->
45 <!-- ================================================================================ -->
46
47 <check level="error" class="org.scalastyle.file.FileTabChecker" enabled="true"></check>
48
49 <check level="error" class="org.scalastyle.file.HeaderMatchesChecker" enabled="true">
50 <parameters>
51 <parameter name="header"><![CDATA[/*
52 * Licensed to the Apache Software Foundation (ASF) under one or more
53 * contributor license agreements. See the NOTICE file distributed with
54 * this work for additional information regarding copyright ownership.
55 * The ASF licenses this file to You under the Apache License, Version 2.0
56 * (the "License"); you may not use this file except in compliance with
57 * the License. You may obtain a copy of the License at
58 *
59 * http://www.apache.org/licenses/LICENSE-2.0
60 *
61 * Unless required by applicable law or agreed to in writing, software
62 * distributed under the License is distributed on an "AS IS" BASIS,
63 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
64 * See the License for the specific language governing permissions and
65 * limitations under the License.
66 */]]></parameter>
67 </parameters>
68 </check>
69
70 <check level="error" class="org.scalastyle.scalariform.SpacesAfterPlusChecker" enabled="true"></check>
71
72 <check level="error" class="org.scalastyle.scalariform.SpacesBeforePlusChecker" enabled="true"></check>
73
74 <check level="error" class="org.scalastyle.file.WhitespaceEndOfLineChecker" enabled="true"></check>
75
76 <check level="error" class="org.scalastyle.file.FileLineLengthChecker" enabled="true">
77 <parameters>
78 <parameter name="maxLineLength"><![CDATA[100]]></parameter>
79 <parameter name="tabSize"><![CDATA[2]]></parameter>
80 <parameter name="ignoreImports">true</parameter>
81 </parameters>
82 </check>
83
84 <check level="error" class="org.scalastyle.scalariform.ClassNamesChecker" enabled="true">
85 <parameters><parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter></parameters>
86 </check>
87
88 <check level="error" class="org.scalastyle.scalariform.ObjectNamesChecker" enabled="true">
89 <parameters><parameter name="regex"><![CDATA[(config|[A-Z][A-Za-z]*)]]></parameter></parameters>
90 </check>
91
92 <check level="error" class="org.scalastyle.scalariform.PackageObjectNamesChecker" enabled="true">
93 <parameters><parameter name="regex"><![CDATA[^[a-z][A-Za-z]*$]]></parameter></parameters>
94 </check>
95
96 <check customId="argcount" level="error" class="org.scalastyle.scalariform.ParameterNumberChecker" enabled="true">
97 <parameters><parameter name="maxParameters"><![CDATA[10]]></parameter></parameters>
98 </check>
99
100 <check level="error" class="org.scalastyle.scalariform.NoFinalizeChecker" enabled="true"></check>
101
102 <check level="error" class="org.scalastyle.scalariform.CovariantEqualsChecker" enabled="true"></check>
103
104 <check level="error" class="org.scalastyle.scalariform.StructuralTypeChecker" enabled="true"></check>
105
106 <check level="error" class="org.scalastyle.scalariform.UppercaseLChecker" enabled="true"></check>
107
108 <check level="error" class="org.scalastyle.scalariform.IfBraceChecker" enabled="true">
109 <parameters>
110 <parameter name="singleLineAllowed"><![CDATA[true]]></parameter>
111 <parameter name="doubleLineAllowed"><![CDATA[true]]></parameter>
112 </parameters>
113 </check>
114
115 <check level="error" class="org.scalastyle.scalariform.PublicMethodsHaveTypeChecker" enabled="true"></check>
116
117 <check level="error" class="org.scalastyle.file.NewLineAtEofChecker" enabled="true"></check>
118
119 <check customId="nonascii" level="error" class="org.scalastyle.scalariform.NonASCIICharacterChecker" enabled="true"></check>
120
121 <check level="error" class="org.scalastyle.scalariform.SpaceAfterCommentStartChecker" enabled="true"></check>
122
123 <check level="error" class="org.scalastyle.scalariform.EnsureSingleSpaceBeforeTokenChecker" enabled="true">
124 <parameters>
125 <parameter name="tokens">ARROW, EQUALS, ELSE, TRY, CATCH, FINALLY, LARROW, RARROW</parameter>
126 </parameters>
127 </check>
128
129 <check level="error" class="org.scalastyle.scalariform.EnsureSingleSpaceAfterTokenChecker" enabled="true">
130 <parameters>
131 <parameter name="tokens">ARROW, EQUALS, COMMA, COLON, IF, ELSE, DO, WHILE, FOR, MATCH, TRY, CATCH, FINALLY, LARROW, RARROW</parameter>
132 </parameters>
133 </check>
134
135 <!-- ??? usually shouldn't be checked into the code base. -->
136 <check level="error" class="org.scalastyle.scalariform.NotImplementedErrorUsage" enabled="true"></check>
137
138 <!-- As of SPARK-7558, all tests in Spark should extend o.a.s.SparkFunSuite instead of FunSuite directly -->
139 <check customId="funsuite" level="error" class="org.scalastyle.scalariform.TokenChecker" enabled="true">
140 <parameters><parameter name="regex">^FunSuite[A-Za-z]*$</parameter></parameters>
141 <customMessage>Tests must extend org.apache.spark.SparkFunSuite instead.</customMessage>
142 </check>
143
144 <!-- As of SPARK-7977 all printlns need to be wrapped in '// scalastyle:off/on println' -->
145 <check customId="println" level="error" class="org.scalastyle.scalariform.TokenChecker" enabled="true">
146 <parameters><parameter name="regex">^println$</parameter></parameters>
147 <customMessage><![CDATA[Are you sure you want to println? If yes, wrap the code block with
148 // scalastyle:off println
149 println(...)
150 // scalastyle:on println]]></customMessage>
151 </check>
152
153 <check customId="visiblefortesting" level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
154 <parameters><parameter name="regex">@VisibleForTesting</parameter></parameters>
155 <customMessage><![CDATA[
156 @VisibleForTesting causes classpath issues. Please note this in the java doc instead (SPARK-11615).
157 ]]></customMessage>
158 </check>
159
160 <check customId="runtimeaddshutdownhook" level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
161 <parameters><parameter name="regex">Runtime\.getRuntime\.addShutdownHook</parameter></parameters>
162 <customMessage><![CDATA[
163 Are you sure that you want to use Runtime.getRuntime.addShutdownHook? In most cases, you should use
164 ShutdownHookManager.addShutdownHook instead.
165 If you must use Runtime.getRuntime.addShutdownHook, wrap the code block with
166 // scalastyle:off runtimeaddshutdownhook
167 Runtime.getRuntime.addShutdownHook(...)
168 // scalastyle:on runtimeaddshutdownhook
169 ]]></customMessage>
170 </check>
171
172 <check customId="mutablesynchronizedbuffer" level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
173 <parameters><parameter name="regex">mutable\.SynchronizedBuffer</parameter></parameters>
174 <customMessage><![CDATA[
175 Are you sure that you want to use mutable.SynchronizedBuffer? In most cases, you should use
176 java.util.concurrent.ConcurrentLinkedQueue instead.
177 If you must use mutable.SynchronizedBuffer, wrap the code block with
178 // scalastyle:off mutablesynchronizedbuffer
179 mutable.SynchronizedBuffer[...]
180 // scalastyle:on mutablesynchronizedbuffer
181 ]]></customMessage>
182 </check>
183
184 <check customId="classforname" level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
185 <parameters><parameter name="regex">Class\.forName</parameter></parameters>
186 <customMessage><![CDATA[
187 Are you sure that you want to use Class.forName? In most cases, you should use Utils.classForName instead.
188 If you must use Class.forName, wrap the code block with
189 // scalastyle:off classforname
190 Class.forName(...)
191 // scalastyle:on classforname
192 ]]></customMessage>
193 </check>
194
195 <check customId="awaitresult" level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
196 <parameters><parameter name="regex">Await\.result</parameter></parameters>
197 <customMessage><![CDATA[
198 Are you sure that you want to use Await.result? In most cases, you should use ThreadUtils.awaitResult instead.
199 If you must use Await.result, wrap the code block with
200 // scalastyle:off awaitresult
201 Await.result(...)
202 // scalastyle:on awaitresult
203 ]]></customMessage>
204 </check>
205
206 <check customId="awaitready" level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
207 <parameters><parameter name="regex">Await\.ready</parameter></parameters>
208 <customMessage><![CDATA[
209 Are you sure that you want to use Await.ready? In most cases, you should use ThreadUtils.awaitReady instead.
210 If you must use Await.ready, wrap the code block with
211 // scalastyle:off awaitready
212 Await.ready(...)
213 // scalastyle:on awaitready
214 ]]></customMessage>
215 </check>
216
217 <!-- As of SPARK-9613 JavaConversions should be replaced with JavaConverters -->
218 <check customId="javaconversions" level="error" class="org.scalastyle.scalariform.TokenChecker" enabled="true">
219 <parameters><parameter name="regex">JavaConversions</parameter></parameters>
220 <customMessage>Instead of importing implicits in scala.collection.JavaConversions._, import
221 scala.collection.JavaConverters._ and use .asScala / .asJava methods</customMessage>
222 </check>
223
224 <check customId="commonslang2" level="error" class="org.scalastyle.scalariform.TokenChecker" enabled="true">
225 <parameters><parameter name="regex">org\.apache\.commons\.lang\.</parameter></parameters>
226 <customMessage>Use Commons Lang 3 classes (package org.apache.commons.lang3.*) instead
227 of Commons Lang 2 (package org.apache.commons.lang.*)</customMessage>
228 </check>
229
230 <check customId="extractopt" level="error" class="org.scalastyle.scalariform.TokenChecker" enabled="true">
231 <parameters><parameter name="regex">extractOpt</parameter></parameters>
232 <customMessage>Use Utils.jsonOption(x).map(.extract[T]) instead of .extractOpt[T], as the latter
233 is slower. </customMessage>
234 </check>
235
236 <check level="error" class="org.scalastyle.scalariform.ImportOrderChecker" enabled="true">
237 <parameters>
238 <parameter name="groups">java,scala,3rdParty,spark</parameter>
239 <parameter name="group.java">javax?\..*</parameter>
240 <parameter name="group.scala">scala\..*</parameter>
241 <parameter name="group.3rdParty">(?!org\.apache\.spark\.).*</parameter>
242 <parameter name="group.spark">org\.apache\.spark\..*</parameter>
243 </parameters>
244 </check>
245
246 <check level="error" class="org.scalastyle.scalariform.DisallowSpaceBeforeTokenChecker" enabled="true">
247 <parameters>
248 <parameter name="tokens">COMMA</parameter>
249 </parameters>
250 </check>
251
252 <!-- SPARK-3854: Single Space between ')' and '{' -->
253 <check customId="SingleSpaceBetweenRParenAndLCurlyBrace" level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
254 <parameters><parameter name="regex">\)\{</parameter></parameters>
255 <customMessage><![CDATA[
256 Single Space between ')' and `{`.
257 ]]></customMessage>
258 </check>
259
260 <check customId="NoScalaDoc" level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
261 <parameters><parameter name="regex">(?m)^(\s*)/[*][*].*$(\r|)\n^\1 [*]</parameter></parameters>
262 <customMessage>Use Javadoc style indentation for multiline comments</customMessage>
263 </check>
264
265 <check customId="OmitBracesInCase" level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
266 <parameters><parameter name="regex">case[^\n>]*=>\s*\{</parameter></parameters>
267 <customMessage>Omit braces in case clauses.</customMessage>
268 </check>
269
270 <!-- SPARK-16877: Avoid Java annotations -->
271 <check level="error" class="org.scalastyle.scalariform.OverrideJavaChecker" enabled="true"></check>
272
273 <check level="error" class="org.scalastyle.scalariform.DeprecatedJavaChecker" enabled="true"></check>
274
275 <!-- ================================================================================ -->
276 <!-- rules we'd like to enforce, but haven't cleaned up the codebase yet -->
277 <!-- ================================================================================ -->
278
279 <!-- We cannot turn the following two on, because it'd fail a lot of string interpolation use cases. -->
280 <!-- Ideally the following two rules should be configurable to rule out string interpolation. -->
281 <check level="error" class="org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker" enabled="false"></check>
282 <check level="error" class="org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker" enabled="false"></check>
283
284 <!-- This breaks symbolic method names so we don't turn it on. -->
285 <!-- Maybe we should update it to allow basic symbolic names, and then we are good to go. -->
286 <check level="error" class="org.scalastyle.scalariform.MethodNamesChecker" enabled="false">
287 <parameters>
288 <parameter name="regex"><![CDATA[^[a-z][A-Za-z0-9]*$]]></parameter>
289 </parameters>
290 </check>
291
292 <!-- Should turn this on, but we have a few places that need to be fixed first -->
293 <check level="error" class="org.scalastyle.scalariform.EqualsHashCodeChecker" enabled="true"></check>
294
295 <!-- ================================================================================ -->
296 <!-- rules we don't want -->
297 <!-- ================================================================================ -->
298
299 <check level="error" class="org.scalastyle.scalariform.IllegalImportsChecker" enabled="false">
300 <parameters><parameter name="illegalImports"><![CDATA[sun._,java.awt._]]></parameter></parameters>
301 </check>
302
303 <!-- We want the opposite of this: NewLineAtEofChecker -->
304 <check level="error" class="org.scalastyle.file.NoNewLineAtEofChecker" enabled="false"></check>
305
306 <!-- This one complains about all kinds of random things. Disable. -->
307 <check level="error" class="org.scalastyle.scalariform.SimplifyBooleanExpressionChecker" enabled="false"></check>
308
309 <!-- We use return quite a bit for control flows and guards -->
310 <check level="error" class="org.scalastyle.scalariform.ReturnChecker" enabled="false"></check>
311
312 <!-- We use null a lot in low level code and to interface with 3rd party code -->
313 <check level="error" class="org.scalastyle.scalariform.NullChecker" enabled="false"></check>
314
315 <!-- Doesn't seem super big deal here ... -->
316 <check level="error" class="org.scalastyle.scalariform.NoCloneChecker" enabled="false"></check>
317
318 <!-- Doesn't seem super big deal here ... -->
319 <check level="error" class="org.scalastyle.file.FileLengthChecker" enabled="false">
320 <parameters><parameter name="maxFileLength">800></parameter></parameters>
321 </check>
322
323 <!-- Doesn't seem super big deal here ... -->
324 <check level="error" class="org.scalastyle.scalariform.NumberOfTypesChecker" enabled="false">
325 <parameters><parameter name="maxTypes">30</parameter></parameters>
326 </check>
327
328 <!-- Doesn't seem super big deal here ... -->
329 <check level="error" class="org.scalastyle.scalariform.CyclomaticComplexityChecker" enabled="false">
330 <parameters><parameter name="maximum">10</parameter></parameters>
331 </check>
332
333 <!-- Doesn't seem super big deal here ... -->
334 <check level="error" class="org.scalastyle.scalariform.MethodLengthChecker" enabled="false">
335 <parameters><parameter name="maxLength">50</parameter></parameters>
336 </check>
337
338 <!-- Not exactly feasible to enforce this right now. -->
339 <!-- It is also infrequent that somebody introduces a new class with a lot of methods. -->
340 <check level="error" class="org.scalastyle.scalariform.NumberOfMethodsInTypeChecker" enabled="false">
341 <parameters><parameter name="maxMethods"><![CDATA[30]]></parameter></parameters>
342 </check>
343
344 <!-- Doesn't seem super big deal here, and we have a lot of magic numbers ... -->
345 <check level="error" class="org.scalastyle.scalariform.MagicNumberChecker" enabled="false">
346 <parameters><parameter name="ignore">-1,0,1,2,3</parameter></parameters>
347 </check>
348
349 </scalastyle>