-
Notifications
You must be signed in to change notification settings - Fork 11
/
scalastyle-config.xml
480 lines (415 loc) · 16.9 KB
/
scalastyle-config.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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
<!--
To disable scalastyle check for a block of code,
// scalastyle:off
... // some block of code
// scalastyle:on
To disable for a single rule,
// scalastyle:off method.name
def ::[B >: A](x: B) = ...
// scalastyle:on method.name
-->
<scalastyle>
<name>Exasol Scala Scalastyle Configurations (adapted from Spark Scala Style Guide)</name>
<!-- Check there are no tabs in a file -->
<check level="error"
class="org.scalastyle.file.FileTabChecker"
enabled="true">
</check>
<!-- Check that the plus sign is followed by a space -->
<check level="error"
class="org.scalastyle.scalariform.SpacesAfterPlusChecker"
enabled="true">
</check>
<!-- Check that the plus sign is preceded by a space -->
<check level="error"
class="org.scalastyle.scalariform.SpacesBeforePlusChecker"
enabled="true">
</check>
<!-- Check that there is no trailing whitespace at the end of lines -->
<check level="error"
class="org.scalastyle.file.WhitespaceEndOfLineChecker"
enabled="true">
</check>
<!-- Check the number of characters in a line -->
<check level="error" class="org.scalastyle.file.FileLineLengthChecker" enabled="true">
<parameters>
<parameter name="maxLineLength"><![CDATA[120]]></parameter>
<parameter name="tabSize"><![CDATA[2]]></parameter>
<parameter name="ignoreImports">true</parameter>
</parameters>
</check>
<!-- Check that class names match a regular expression -->
<check level="error" class="org.scalastyle.scalariform.ClassNamesChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
</parameters>
</check>
<!-- Check that object names match a regular expression -->
<check level="error" class="org.scalastyle.scalariform.ObjectNamesChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[[A-Z][A-Za-z]*]]></parameter>
</parameters>
</check>
<!-- Check that package object names match a regular expression -->
<check level="error"
class="org.scalastyle.scalariform.PackageObjectNamesChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[^[a-z][A-Za-z]*$]]></parameter>
</parameters>
</check>
<!-- Maximum number of parameters for a method, after a certain number
can be hard to understand and keep track
-->
<check level="error" class="org.scalastyle.scalariform.ParameterNumberChecker" enabled="true">
<parameters>
<parameter name="maxParameters"><![CDATA[8]]></parameter>
</parameters>
</check>
<!-- Check that classes and objects do not define the finalize() method -->
<check level="error"
class="org.scalastyle.scalariform.NoFinalizeChecker"
enabled="true">
</check>
<!-- Check that classes and objects do not define equals without overriding
equals(java.lang.Object)
-->
<check level="error"
class="org.scalastyle.scalariform.CovariantEqualsChecker"
enabled="true">
</check>
<!-- Structural types in Scala can use reflection - this can have unexpected
performance consequences
-->
<check level="error"
class="org.scalastyle.scalariform.StructuralTypeChecker"
enabled="true">
</check>
<!-- Checks that if a long literal is used, then an uppercase L is used -->
<check level="error"
class="org.scalastyle.scalariform.UppercaseLChecker"
enabled="true">
</check>
<!-- Checks that if statements have braces -->
<check level="error" class="org.scalastyle.scalariform.IfBraceChecker" enabled="true">
<parameters>
<parameter name="singleLineAllowed"><![CDATA[true]]></parameter>
<parameter name="doubleLineAllowed"><![CDATA[false]]></parameter>
</parameters>
</check>
<!-- Check that a method has an explicit return type, it is not inferred -->
<check level="error"
class="org.scalastyle.scalariform.PublicMethodsHaveTypeChecker" enabled="true">
<parameters>
<parameter name="ignoreOverride">false</parameter>
</parameters>
</check>
<!-- Checks that a file ends with a newline character -->
<check level="error"
class="org.scalastyle.file.NewLineAtEofChecker"
enabled="true">
</check>
<!-- Checks that non-ascii characters are not used. Some editors are unfriendly
to non ascii characters.
-->
<check customId="nonascii"
level="error"
class="org.scalastyle.scalariform.NonASCIICharacterChecker"
enabled="true">
</check>
<!-- Checks a space after the start of the comment -->
<check level="error"
class="org.scalastyle.scalariform.SpaceAfterCommentStartChecker"
enabled="true">
</check>
<!-- Ensure single space before certain token(s) -->
<check level="error"
class="org.scalastyle.scalariform.EnsureSingleSpaceBeforeTokenChecker"
enabled="true">
<parameters>
<parameter name="tokens">EQUALS, ELSE, TRY, CATCH, FINALLY, LARROW, RARROW</parameter>
</parameters>
</check>
<!-- Ensure single space after certain token(s) -->
<check level="error"
class="org.scalastyle.scalariform.EnsureSingleSpaceAfterTokenChecker"
enabled="true">
<parameters>
<parameter name="tokens">ARROW, EQUALS, COMMA, COLON, IF, ELSE, DO, WHILE, FOR, MATCH, TRY, CATCH, FINALLY, LARROW, RARROW</parameter>
</parameters>
</check>
<!-- Checks '???' are not checked into the code base -->
<check level="error"
class="org.scalastyle.scalariform.NotImplementedErrorUsage"
enabled="true">
</check>
<!-- Custom Check: 'println' should not be used -->
<check customId="println"
level="error" class="org.scalastyle.scalariform.TokenChecker" enabled="true">
<parameters>
<parameter name="regex">^println$</parameter>
</parameters>
<customMessage><![CDATA[
Are you sure you want to println? If yes, wrap the code block with
// scalastyle:off println
println(...)
// scalastyle:on println]]>
</customMessage>
</check>
<!-- Custom Check: 'mutable.SynchronizedBuffer' should not be used -->
<check customId="mutableSynchronizedbuffer"
level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex">mutable\.SynchronizedBuffer</parameter>
</parameters>
<customMessage><![CDATA[
Are you sure that you want to use mutable.SynchronizedBuffer?
In most cases, you should use java.util.concurrent.ConcurrentLinkedQueue instead.
If you must use mutable.SynchronizedBuffer, wrap the code block with
// scalastyle:off mutablesynchronizedbuffer
mutable.SynchronizedBuffer[...]
// scalastyle:on mutablesynchronizedbuffer]]>
</customMessage>
</check>
<!-- Custom Check: 'Class.forName' should not be used -->
<check customId="classForName"
level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex">Class\.forName</parameter>
</parameters>
<customMessage><![CDATA[
Are you sure that you want to use Class.forName?
In most cases, you should use Utils.classForName instead.
If you must use Class.forName, wrap the code block with
// scalastyle:off classForName
Class.forName(...)
// scalastyle:on classForName]]>
</customMessage>
</check>
<!-- Custom Check: 'Await.result' should not be used -->
<check customId="awaitResult"
level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex">Await\.result</parameter>
</parameters>
<customMessage><![CDATA[
Are you sure that you want to use Await.result?
In most cases, you should use ThreadUtils.awaitResult instead.
If you must use Await.result, wrap the code block with
// scalastyle:off awaitresult
Await.result(...)
// scalastyle:on awaitresult]]>
</customMessage>
</check>
<!-- Custom Check: 'Await.ready' should not be used -->
<check customId="awaitReady"
level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex">Await\.ready</parameter>
</parameters>
<customMessage><![CDATA[
Are you sure that you want to use Await.ready?
In most cases, you should use ThreadUtils.awaitReady instead.
If you must use Await.ready, wrap the code block with
// scalastyle:off awaitready
Await.ready(...)
// scalastyle:on awaitready]]>
</customMessage>
</check>
<!-- Custom Check: 'JavaConverters' should be used instead of 'JavaConversions' -->
<check customId="javaConversions"
level="error" class="org.scalastyle.scalariform.TokenChecker" enabled="true">
<parameters>
<parameter name="regex">JavaConversions</parameter>
</parameters>
<customMessage><![CDATA[
Instead of importing implicits in scala.collection.JavaConversions._
use instead import scala.collection.JavaConverters._
and use .asScala / .asJava methods]]>
</customMessage>
</check>
<!-- Custom Check: 'apache.commons.lang3' should be used instead of 'apache.commons.lang' -->
<check customId="commonsLang2"
level="error" class="org.scalastyle.scalariform.TokenChecker" enabled="true">
<parameters>
<parameter name="regex">org\.apache\.commons\.lang\.</parameter>
</parameters>
<customMessage><![CDATA[
Use Commons Lang 3 classes (package org.apache.commons.lang3.*)
instead of Commons Lang 2 (package org.apache.commons.lang.*)]]>
</customMessage>
</check>
<!-- Custom Check: 'jsonOption(x).map(.extract[T])' should be used
instead of '.extractOpt[T]'
-->
<check customId="extractOpt"
level="error" class="org.scalastyle.scalariform.TokenChecker" enabled="true">
<parameters>
<parameter name="regex">extractOpt</parameter>
</parameters>
<customMessage><![CDATA[
Use jsonOption(x).map(.extract[T]) instead of .extractOpt[T],
as the latter is slower.]]>
</customMessage>
</check>
<!-- Custom Check: There should be space between ')' and '{' -->
<check customId="singleSpaceBetweenRParenAndLCurlyBrace"
level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex">\)\{</parameter>
</parameters>
<customMessage><![CDATA[
There should be a single space character between ')' and `{`]]>
</customMessage>
</check>
<!-- Custom Check: JavaDoc style should be used -->
<check customId="noScalaDoc"
level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex">(?m)^(\s*)/[*][*].*$(\r|)\n^\1 [*]</parameter>
</parameters>
<customMessage><![CDATA[
Use Javadoc style indentation for multiline comments]]>
</customMessage>
</check>
<!-- Custom Check: Braces should be omitted in case clauses -->
<check customId="omitBracesInCase"
level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex">case[^\n>]*=>\s*\{</parameter>
</parameters>
<customMessage><![CDATA[
Braces in case clauses should be omitted]]>
</customMessage>
</check>
<!-- Custom Check: Ensure exactly one space between 'if' and '(' -->
<check customId="if.paren.spacing"
level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[if\(|if\s\s+\(]]></parameter>
</parameters>
<customMessage><![CDATA[
Put exactly a single space between 'if' and the following parenthesis]]>
</customMessage>
</check>
<!-- Checks that imports are grouped and ordered according to the style configuration -->
<!-- Disabled since imports are organized by Scalafix linting. -->
<check level="error" class="org.scalastyle.scalariform.ImportOrderChecker" enabled="false">
<parameters>
<parameter name="groups">java,scala,exasol,others</parameter>
<parameter name="group.java">javax?\..*</parameter>
<parameter name="group.scala">scala\..*</parameter>
<parameter name="group.exasol">com\.exasol\..*</parameter>
<parameter name="group.others">.*</parameter>
</parameters>
</check>
<!-- Disallow space before certain token(s) -->
<check level="error"
class="org.scalastyle.scalariform.DisallowSpaceBeforeTokenChecker"
enabled="true">
<parameters>
<parameter name="tokens">COMMA</parameter>
</parameters>
</check>
<!-- Checks that Java @Override is not used, Scala override keyword should be used instead -->
<check level="error"
class="org.scalastyle.scalariform.OverrideJavaChecker"
enabled="true">
</check>
<!-- Checks that Java @Deprecated is not used, Scala @deprecated should be used instead -->
<check level="error"
class="org.scalastyle.scalariform.DeprecatedJavaChecker"
enabled="true">
</check>
<!-- No whitespace before left bracket '[', this can be confusing to the reader -->
<check level="error"
class="org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker"
enabled="true">
</check>
<!-- No whitespace after left bracket '[', this can be confusing to the reader -->
<check level="error"
class="org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker"
enabled="true">
</check>
<!-- Check that method names match a regular expression -->
<check level="error" class="org.scalastyle.scalariform.MethodNamesChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[^[a-z][A-Za-z0-9]*$]]></parameter>
</parameters>
</check>
<!-- Checks that methods do not exceed a maximum length -->
<check level="warn" class="org.scalastyle.scalariform.MethodLengthChecker" enabled="true">
<parameters>
<parameter name="maxLength"><![CDATA[120]]></parameter>
</parameters>
</check>
<!-- Check that a class / trait / object does not have too many methods -->
<check level="error"
class="org.scalastyle.scalariform.NumberOfMethodsInTypeChecker" enabled="true">
<parameters>
<parameter name="maxMethods"><![CDATA[30]]></parameter>
</parameters>
</check>
<!-- Checks that the cyclomatic complexity of a method does exceed a value
If the code is too complex, then this can make code hard to read.
-->
<check level="warn"
class="org.scalastyle.scalariform.CyclomaticComplexityChecker" enabled="true">
<parameters>
<parameter name="maximum"><![CDATA[100]]></parameter>
</parameters>
</check>
<!-- Check that if a class implements either equals or hashCode,
it should implement the other
-->
<check level="error"
class="org.scalastyle.scalariform.EqualsHashCodeChecker"
enabled="true">
</check>
<!-- Checks for use of magic numbers, avoids assignments like: var baz = 4 -->
<check level="warn" class="org.scalastyle.scalariform.MagicNumberChecker" enabled="false">
<parameters>
<parameter name="ignore"><![CDATA[-1,0,1,2,3,4,5,6,7]]></parameter>
</parameters>
</check>
<!-- Check that return is not used -->
<check level="error" class="org.scalastyle.scalariform.ReturnChecker" enabled="true"></check>
<!-- Check that null is not used, prefer Option if possible -->
<check level="error" class="org.scalastyle.scalariform.NullChecker" enabled="false"></check>
<!-- Check that classes and objects do not define the clone() method -->
<check level="error" class="org.scalastyle.scalariform.NoCloneChecker" enabled="true"></check>
<!-- A boolean expression which can be simplified can make code easier to read -->
<check level="error"
class="org.scalastyle.scalariform.SimplifyBooleanExpressionChecker"
enabled="true">
</check>
<!-- Checks that braces are used in for comprehensions -->
<check level="error" class="org.scalastyle.scalariform.ForBraceChecker" enabled="true"/>
<!-- Checks that if expressions are not redundant, i.e. easily replaced
by a variant of the condition
-->
<check level="error" class="org.scalastyle.scalariform.RedundantIfChecker" enabled="true"/>
<!-- Use a : Unit = for procedure declarations -->
<check level="error"
class="org.scalastyle.scalariform.ProcedureDeclarationChecker"
enabled="true"/>
<!-- Checks that there are not too many types declared in a file -->
<check level="error" class="org.scalastyle.scalariform.NumberOfTypesChecker" enabled="true">
<parameters>
<parameter name="maxTypes"><![CDATA[30]]></parameter>
</parameters>
</check>
<!-- Check a file lines does not exceed threshold (800 default) -->
<check level="error" class="org.scalastyle.file.FileLengthChecker" enabled="true">
<parameters>
<parameter name="maxFileLength"><![CDATA[800]]></parameter>
</parameters>
</check>
<!-- Check that certain classes are not imported -->
<check level="error" class="org.scalastyle.scalariform.IllegalImportsChecker" enabled="true">
<parameters>
<parameter name="illegalImports"><![CDATA[sun._,java.awt._]]></parameter>
</parameters>
</check>
<!-- We want the opposite of this: NewLineAtEofChecker -->
<check level="error" class="org.scalastyle.file.NoNewLineAtEofChecker" enabled="false"></check>
</scalastyle>