-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
spotbugs.xml
543 lines (452 loc) · 20.4 KB
/
spotbugs.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
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter
xmlns="https://github.com/spotbugs/filter/3.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://github.com/spotbugs/filter/3.0.0 https://raw.githubusercontent.com/spotbugs/spotbugs/3.1.0/spotbugs/etc/findbugsfilter.xsd">
<!-- Bug descriptions: http://spotbugs.readthedocs.io/en/latest/bugDescriptions.html -->
<!-- Filter file format: http://spotbugs.readthedocs.io/en/latest/filter.html -->
<!-- Match all violations. -->
<!-- But ignore these:
* comparator should be serializable
* something else dealing with serialization
* format string should use %n instead of /n
* inner class should be static (awkard, but possible with generics)
* using entrySet() is more efficient than keySet(), but it is awkward
* uses non-localized toLowerCase() or toUpperCase()
* switch statement with no default; seems OK when used for cases with (int) (4 * Math.random())
* class naming convention (defer to Checkstyle)
* method naming convention (defer to Checkstyle)
* unused field (defer to PMD/IntelliJ since it highlight entire class)
* class defines compareTo() and inherits equals()
-->
<Match>
<BugPattern name="SE_COMPARATOR_SHOULD_BE_SERIALIZABLE,
SE_BAD_FIELD,
VA_FORMAT_STRING_USES_NEWLINE,
SIC_INNER_SHOULD_BE_STATIC,
WMI_WRONG_MAP_ITERATOR,
DM_CONVERT_CASE,
SF_SWITCH_NO_DEFAULT,
NM_METHOD_NAMING_CONVENTION,
NM_CLASS_NAMING_CONVENTION,
NM_FIELD_NAMING_CONVENTION,
EQ_COMPARETO_USE_OBJECT_EQUALS" />
</Match>
<!-- from fb-contrib-7.4.3.jar plugin -->
<!-- FCBL_FIELD_COULD_BE_LOCAL redundant with PMD -->
<!-- PME_POOR_MANS_ENUM we disallow enum and seems to have false positives -->
<!-- OCP_OVERLY_CONCRETE_PARAMETER wants Picture to be defines as java.awt.event.ActionListener -->
<!-- NAB_NEEDLESS_BOXING_VALUEOF wants stack.push(Integer.valueOf(s)) instead of stack.push(Integer.parseInt(s)) -->
<!-- CBX_CUSTOM_BUILT_XML flags StdOut.println("> " + (r1.size() == 0)); -->
<!-- TODO: Java 7 - replace CHARSET_NAME with java.nio.charset.StandardCharsets.UTF_8 and eliminate
CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET,
CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET_NAME,
-->
<!-- TODO: use java.nio.file.Files.newInputStream and java.nio.file.Files.newOutputStream
to eliminate IOI_USE_OF_FILE_STREAM_CONSTRUCTORS
-->
<Match>
<BugPattern name="AI_ANNOTATION_ISSUES_NEEDS_NULLABLE,
BL_BURYING_LOGIC,
CBX_CUSTOM_BUILT_XML,
CC_CYCLOMATIC_COMPLEXITY,
CE_CLASS_ENVY,
CLI_CONSTANT_LIST_INDEX,
CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET,
CSI_CHAR_SET_ISSUES_USE_STANDARD_CHARSET_NAME,
EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS,
FCBL_FIELD_COULD_BE_LOCAL,
CNC_COLLECTION_NAMING_CONFUSION,
IMC_IMMATURE_CLASS_NO_EQUALS,
IMC_IMMATURE_CLASS_NO_PACKAGE,
IMC_IMMATURE_CLASS_NO_TOSTRING,
IMC_IMMATURE_CLASS_NO_HASHCODE,
IMC_IMMATURE_CLASS_WRONG_FIELD_ORDER,
IOI_USE_OF_FILE_STREAM_CONSTRUCTORS,
ISB_EMPTY_STRING_APPENDING,
ISB_INEFFICIENT_STRING_BUFFERING,
ISB_TOSTRING_APPENDING,
LSC_LITERAL_STRING_COMPARISON,
MAC_MANUAL_ARRAY_COPY,
MDM_RANDOM_SEED,
MUI_CONTAINSKEY_BEFORE_GET,
NAB_NEEDLESS_BOXING_VALUEOF,
OPM_OVERLY_PERMISSIVE_METHOD,
OCP_OVERLY_CONCRETE_PARAMETER,
PCOA_PARTIALLY_CONSTRUCTED_OBJECT_ACCESS,
PCAIL_POSSIBLE_CONSTANT_ALLOCATION_IN_LOOP,
PL_PARALLEL_LISTS,
PME_POOR_MANS_ENUM,
PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS,
PSC_PRESIZE_COLLECTIONS,
S508C_NON_TRANSLATABLE_STRING,
SACM_STATIC_ARRAY_CREATED_IN_METHOD,
SCR_SLOPPY_CLASS_REFLECTION,
SEO_SUBOPTIMAL_EXPRESSION_ORDER,
SPP_TEMPORARY_TRIM,
STT_STRING_PARSING_A_FIELD,
UCPM_USE_CHARACTER_PARAMETERIZED_METHOD,
USBR_UNNECESSARY_STORE_BEFORE_RETURN,
UVA_USE_VAR_ARGS,
URF_UNREAD_FIELD,
UUF_UNUSED_FIELD,
WEM_WEAK_EXCEPTION_MESSAGING" />
</Match>
<!-- Ignore DLS_DEAD_LOCAL_STORE for low-confidence warnings (3)
Otherwise it will flag code like the following:
for (String x : set)
count++;
-->
<Match>
<BugPattern name="DLS_DEAD_LOCAL_STORE, UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" />
<Confidence value="3" />
</Match>
<!-- Ignore SCRV_SUSPICIOUS_COMPARATOR_RETURN_VALUES for low-confidence warnings (3)
to avoid false positives in compare() -->
<Match>
<BugPattern name="SCRV_SUSPICIOUS_COMPARATOR_RETURN_VALUES" />
<Confidence value="3" />
</Match>
<!-- *********************************************************************** -->
<!-- STDLIB.JAR EXCEPTIONS -->
<!-- *********************************************************************** -->
<Match>
<Class name = "~.*(Std)?Draw" />
<BugPattern name="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD, DE_MIGHT_IGNORE" />
</Match>
<Match>
<Class name = "~.*StdAudio" />
<BugPattern name="DM_EXIT" />
</Match>
<Match>
<Class name = "~.*In" />
<BugPattern name="DMI_HARDCODED_ABSOLUTE_FILENAME" />
</Match>
<Match>
<Class name = "~.*(In|StdIn)" />
<BugPattern name="LEST_LOST_EXCEPTION_STACK_TRACE" />
</Match>
<Match>
<Class name = "~.*(BinaryIn|BinaryOut|BinaryStdIn|BinaryStdOut)" />
<BugPattern name="FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY" />
</Match>
<Match>
<Class name = "~.*(BinaryOut|BinaryStdOut|Draw|Out|Picture|StdAudio|StdDraw)" />
<BugPattern name="IMC_IMMATURE_CLASS_PRINTSTACKTRACE" />
</Match>
<Match>
<Class name = "~.*(Draw|StdDraw)" />
<BugPattern name="MDM_THREAD_YIELD" />
</Match>
<!-- false positive -->
<Match>
<Class name = "~.*(StdRandom)" />
<Method name="poisson" params="double" returns="int" />
<BugPattern name="MRC_METHOD_RETURNS_CONSTANT" />
</Match>
<!-- *********************************************************************** -->
<!-- INTRO TO PROGRAMMING IN JAVA EXCEPTIONS -->
<!-- *********************************************************************** -->
<Match>
<Class name = "~.*Bug.*" />
</Match>
<Match>
<Class name = "Confusion" />
<BugPattern name="SA_LOCAL_SELF_ASSIGNMENT, DLS_OVERWRITTEN_INCREMENT" />
</Match>
<!-- Double.valueOf() not introduced, so better to use Double.parseDouble() -->
<Match>
<Class name = "Evaluate" />
<BugPattern name="NAB_NEEDLESS_BOXING_VALUEOF" />
</Match>
<Match>
<Class name = "PassByValue" />
<BugPattern name="IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN" />
</Match>
<Match>
<Class name = "ArrayExamples" />
<BugPattern name="DMI_INVOKING_TOSTRING_ON_ARRAY" />
</Match>
<Match>
<Class name = "PhoneNumber" />
<BugPattern name="SA_LOCAL_SELF_COMPARISON" />
</Match>
<Match>
<Class name = "HashCode" />
<BugPattern name="ES_COMPARING_STRINGS_WITH_EQ,DM_STRING_CTOR" />
</Match>
<Match>
<Class name = "~NoBaseCase|NoConvergence" />
<BugPattern name="IL_INFINITE_RECURSIVE_LOOP" />
</Match>
<!-- Exclude Gaussian.Phi() test for floating-point equality. -->
<Match>
<Class name = "Gaussian" />
<BugPattern name="FE_FLOATING_POINT_EQUALITY" />
</Match>
<!-- generating random integers before StdRandom.uniform() is introduced -->
<Match>
<Class name = "~Coupon|CouponCollector|TwentyQuestions|Craps|Functions|
|Mozart|Birthday|Birthdays|RollDie|SumOfTwoDice|
|RandomStudent|Sicherman|Chaos|DiscreteDistribution|
|MonteHall|MostLikelyRoll" />
<BugPattern name="DM_NEXTINT_VIA_NEXTDOUBLE" />
</Match>
<!-- string concatenation before StringBuffer is introduced -->
<Match>
<Class name = "~RulerN|DigitReverser|Loops|LongestCommonSubsequence|
|ThueMorse|Ordinal|DeBruijn|Soundex|Repeat|
|Quote|CircularQuote" />
<BugPattern name="SBSC_USE_STRINGBUFFER_CONCATENATION" />
</Match>
<!-- we are measuring side effect of elapsed time -->
<Match>
<Class name = "DoublingTest" />
<BugPattern name="DLS_DEAD_LOCAL_STORE" />
</Match>
<!-- *********************************************************************** -->
<!-- ALGS4.JAR EXCEPTIONS -->
<!-- *********************************************************************** -->
<!-- techincally, need (edu\.princeton\.cs\.algs4\.)? instead of .* for package version -->
<Match>
<Class name = "~.*(BellmanFordSP|DijkstraSP|DynamicProgrammingSP|UniqueMincut|
|Hungarian|DijkstraUndirectedSP)" />
<BugPattern name="FE_FLOATING_POINT_EQUALITY" />
</Match>
<Match>
<Class name = "~.*Doubling.*" />
<BugPattern name="RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT,UC_USELESS_OBJECT" />
</Match>
<Match>
<Class name = "~(Autoboxing|DualPivotQuicksort)" />
</Match>
<Match>
<Class name = "~Mutable(String|Integer)" />
<BugPattern name="DP_DO_INSIDE_DO_PRIVILEGED" />
</Match>
<Match>
<Class name = "~AntiQuicksorter.*" />
<BugPattern name="HE_EQUALS_USE_HASHCODE, HE_EQUALS_NO_HASHCODE" />
</Match>
<Match>
<Class name = "BrokenShuffle" />
<BugPattern name="DM_NEXTINT_VIA_NEXTDOUBLE" />
</Match>
<Match>
<Class name = "~.*RabinKarp" />
<BugPattern name="UPM_UNCALLED_PRIVATE_METHOD" />
</Match>
<Match>
<Class name = "CovariantPhoneNumber" />
<BugPattern name="EQ_SELF_USE_OBJECT" />
</Match>
<Match>
<Class name = "~.*MemoryOf.*" />
<BugPattern name="DM_NUMBER_CTOR" />
</Match>
<Match>
<Class name = "Concatenate" />
<BugPattern name="SBSC_USE_STRINGBUFFER_CONCATENATION" />
</Match>
<Match>
<Class name = "~(edu.princeton.cs.algs4.)?Student" />
<BugPattern name="SA_LOCAL_SELF_COMPARISON, EC_UNRELATED_TYPES" />
</Match>
<Match>
<Class name = "~(edu.princeton.cs.algs4.)?Person" />
<BugPattern name="SA_LOCAL_SELF_COMPARISON" />
</Match>
<!-- These properly handle NaN and -0.0 -->
<Match>
<Class name = "~(edu.princeton.cs.algs4.)?(Transaction|Interval1D|Point2D).*" />
<BugPattern name="FE_FLOATING_POINT_EQUALITY,CO_COMPARETO_INCORRECT_FLOATING" />
</Match>
<Match>
<Class name = "~(edu.princeton.cs.algs4.)?(GaussJordanElimination|GaussianElimination)" />
<BugPattern name="PZLA_PREFER_ZERO_LENGTH_ARRAYS" />
</Match>
<Match>
<Class name = "~.*(SET)" />
<BugPattern name="ITU_INAPPROPRIATE_TOSTRING_USE,OCP_OVERLY_CONCRETE_PARAMETER" />
</Match>
<Match>
<Class name = "~.*((Index)?(Binomial|Fibonacci)(Min|Max)PQ)" />
<BugPattern name="CFS_CONFUSING_FUNCTION_SEMANTICS" />
</Match>
<!-- *********************************************************************** -->
<!-- COS 126 PROGRAMMING ASSIGNMENT EXCEPTIONS -->
<!-- *********************************************************************** -->
<!-- n will always be non-negative -->
<Match>
<Class name = "~(Checkerboard)(126)?" />
<BugPattern name="IM_BAD_CHECK_FOR_ODD" />
</Match>
<!-- generating random integers before StdRandom.uniform() is introduced -->
<Match>
<Class name = "~(RollDice|TenDice|RandomWalker|RandomWalkers|Art|MusicalDiceGame|PerfectShuffle)(126)?" />
<BugPattern name="DM_NEXTINT_VIA_NEXTDOUBLE" />
</Match>
<!-- ok to return null in copy() if argument is null -->
<Match>
<Class name = "~(Transform2D)(126)?" />
<Method name="copy" params="double[]" returns="double[]" />
<BugPattern name="PZLA_PREFER_ZERO_LENGTH_ARRAYS" />
</Match>
<!-- GUI is side effect -->
<Match>
<Class name = "Keyboard" />
<BugPattern name="DLS_DEAD_LOCAL_STORE" />
</Match>
<!-- need to read m, width, and height for training images, but don't need to store -->
<Match>
<Class name = "ImageClassifier" />
<BugPattern name="DLS_DEAD_LOCAL_STORE" />
</Match>
<!-- false positive in LFSR with String instance variable -->
<Match>
<Class name = "~(LFSR)" />
<BugPattern name="STT_TOSTRING_STORED_IN_FIELD" />
</Match>
<!-- string concatenation before StringBuffer is introduced -->
<Match>
<Class name = "~(LFSR|MarkovModel|Perceptron|MultiPerceptron)(126)?" />
<BugPattern name="SBSC_USE_STRINGBUFFER_CONCATENATION" />
</Match>
<Match>
<Class name = "~(RingBuffer)(126)?" />
<Method name="toString" params="" returns="java.lang.String" />
<BugPattern name="SBSC_USE_STRINGBUFFER_CONCATENATION" />
</Match>
<!--
<Match>
<Class name = "~(MarkovModel)(126)?" />
<Method name="main" />
<BugPattern name="SBSC_USE_STRINGBUFFER_CONCATENATION" />
</Match>
-->
<!-- *********************************************************************** -->
<!-- COS 126 PROGRAMMING EXAM EXCEPTIONS -->
<!-- *********************************************************************** -->
<!-- string concatenation before StringBuffer is introduced -->
<Match>
<Class name = "~PokerHand|PokerHandWild|Language" />
<BugPattern name="SBSC_USE_STRINGBUFFER_CONCATENATION" />
</Match>
<!-- *********************************************************************** -->
<!-- COURSERA PROGRAMMING WITH A PURPOSE EXCEPTIONS -->
<!-- *********************************************************************** -->
<!-- generating random integers before StdRandom.uniform() is introduced -->
<Match>
<Class name = "~(RandomWalk|RandomWalkers|DiscreteDistribution|Minesweeper|Birthday)(126)?" />
<BugPattern name="DM_NEXTINT_VIA_NEXTDOUBLE" />
</Match>
<!-- *********************************************************************** -->
<!-- COS 226 / COURSERA PROGRAMMING ASSIGNMENT EXCEPTIONS -->
<!-- *********************************************************************** -->
<!-- Exclude compare() by slope order in Point.java on collinear assignment -->
<!-- It produces a warning even though it properly handles NaN -->
<Match>
<Class name = "~Point.*(226)?" />
<BugPattern name="CO_COMPARETO_INCORRECT_FLOATING" />
</Match>
<!-- Exclude compare() by slope order in Point.java on collinear assignment -->
<!-- It produces a warning even though it properly handles NaN -->
<Match>
<Class name = "~(LineSegment)(226)?" />
<BugPattern name="HE_HASHCODE_USE_OBJECT_EQUALS" />
</Match>
<!-- ok to call x.compareTo(x) when unit testing Term -->
<Match>
<Class name = "~(Term)(226)?" />
<Method name="main" />
<BugPattern name="SA_LOCAL_SELF_COMPARISON" />
</Match>
<!-- n will always be non-negative -->
<Match>
<Class name = "~(Board|KdTreeST|KdTree)(226)?" />
<BugPattern name="IM_BAD_CHECK_FOR_ODD" />
</Match>
<!-- ok to call board.equals(null), board.equals(string), or board.equals(board) when unit testing Board -->
<Match>
<Class name = "~(Board)(226)?" />
<Method name="main" />
<BugPattern name="EC_NULL_ARG,EC_UNRELATED_TYPES,SA_LOCAL_SELF_COMPARISON" />
</Match>
<!-- slider puzzle, before we've introduced hashCode() -->
<Match>
<Class name = "~(Board)(226)?" />
<BugPattern name="HE_EQUALS_USE_HASHCODE, HE_EQUALS_NO_HASHCODE" />
</Match>
<!-- BST style code for insert() -->
<Match>
<Class name = "~(KdTree|KdTreeST)(226)?" />
<BugPattern name="CFS_CONFUSING_FUNCTION_SEMANTICS" />
</Match>
<!-- SCUtility not very well designed, but it's our class -->
<Match>
<Class name = "~(SCUtility)" />
<BugPattern name="FCCD_FIND_CLASS_CIRCULAR_DEPENDENCY" />
</Match>
<!-- some false positives -->
<Match>
<Class name = "~(SeamCarver)" />
<BugPattern name="SLS_SUSPICIOUS_LOOP_SEARCH" />
</Match>
<!-- BoggleBoard doesn't implement hashCode() or equals() and does safe test for floating-point equality -->
<Match>
<Class name = "~(BoggleBoard)(226)?" />
<BugPattern name="FE_FLOATING_POINT_EQUALITY,HE_HASHCODE_USE_OBJECT_EQUALS" />
</Match>
<!-- *********************************************************************** -->
<!-- AUTOGRADER -->
<!-- *********************************************************************** -->
<!-- allow methods in *API to return null or false without complaints -->
<Match>
<Class name = "~.*API" />
<BugPattern name="PZLA_PREFER_ZERO_LENGTH_ARRAYS,
NP_TOSTRING_COULD_RETURN_NULL,
UP_UNUSED_PARAMETER,
MRC_METHOD_RETURNS_CONSTANT,
EQ_ALWAYS_FALSE" />
</Match>
<!-- allow methods to write to static instance variables ending in "count" -->
<!-- allow methods to store operation counts that are not currently used -->
<Match>
<Field name = "~.*[Cc]ount" />
<BugPattern name="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD,
URF_UNREAD_FIELD" />
</Match>
<Match>
<Class name = "~.*TimingData" />
<BugPattern name="FCBL_FIELD_COULD_BE_LOCAL" />
</Match>
<!-- allow methods to store values in variables named "ignore.*" -->
<Match>
<Local name = "~.*[Ii]gnore.*" />
<BugPattern name="DLS_DEAD_LOCAL_STORE" />
</Match>
<Match>
<Class name = "~ScreenPrimitiveContainer.*" />
<BugPattern name="HE_EQUALS_USE_HASHCODE, HE_EQUALS_NO_HASHCODE" />
</Match>
<Match>
<Class name = "LineSegment" />
<BugPattern name="HE_EQUALS_USE_HASHCODE, HE_EQUALS_NO_HASHCODE" />
</Match>
<Match>
<Class name = "~Test.*" />
<Method name = "~extract.*" />
<BugPattern name="PZLA_PREFER_ZERO_LENGTH_ARRAYS" />
</Match>
<Match>
<Class name = "~(Test|Time).*" />
<BugPattern name="EXS_EXCEPTION_SOFTENING_RETURN_FALSE,
RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE" />
</Match>
<!-- *********************************************************************** -->
<!-- JAVA MATRIX PACKAGE -->
<!-- *********************************************************************** -->
<Match>
<Class name = "~Jama\..*" />
</Match>
</FindBugsFilter>