-
Notifications
You must be signed in to change notification settings - Fork 133
/
SampleCodeNarcHtmlReport.html
691 lines (644 loc) · 141 KB
/
SampleCodeNarcHtmlReport.html
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
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
<html><head><title>CodeNarc Report: Sample Project</title><style type='text/css'>body {
font-family: Arial, sans-serif;
margin: 20px 20px 20px 30px;
}
h1, h2, h3 {
font-weight: bold;
}
h1 {
width: 400px;
text-align: center;
color: white;
background-color: #557799;
padding: 10px;
-moz-box-shadow: 3px 3px 4px #AAA;
-webkit-box-shadow: 3px 3px 4px #AAA;
box-shadow: 3px 3px 4px #AAA;
border-radius: 10px;
-moz-border-radius: 10px;
text-shadow: 2px 2px 2px black;
}
h2 {
font-size: 150%;
margin-top: 40px;
padding-top: 5px;
border-top: 5px solid lightgray;
}
h3 {
margin-left: 10px;
margin-top: 30px;
}
a {
text-decoration: underline;
color: #D93544;
}
.logo {
float: right;
}
.metadata {
}
.summary {
margin-bottom: 20px;
}
.reportInfo {
font-size: 110%;
}
.allPackages {
font-weight: bold;
}
.fileHeader {
font-size: 120%;
font-weight: bold;
}
.tableHeader {
font-weight: bold;
}
.number {
text-align: center;
}
.priority1, .priority2, .priority3, .priority4 {
font-weight: bold;
text-align: center;
color: #990000;
}
.priority1 {
background-color: #FFAAAA;
}
.priority2 {
background-color: #FFCCAA;
}
.priority3 {
background-color: #FFEEAA;
}
.ruleName {
font-weight: bold;
color: black;
text-align: left;
}
.violationInfo {
margin-bottom: 2px;
margin-top: 2px;
}
.violationInfoPrefix {
font-size: 60%;
width: 30px;
color: #a9a9a9;
padding-right: 4px;
}
.sourceCode {
font-family: Arial, sans-serif;
font-size: 80%;
color: #444444;
}
.violationMessage {
font-style: italic;
font-size: 80%;
color: black;
}
.ruleDescriptions {
font-size: 85%;
}
.version {
margin-top: 1px;
}
.buttons button {
margin-right: 10px;
margin-bottom: 10px;
}
table {
border: 2px solid gray;
border-collapse: collapse;
-moz-box-shadow: 3px 3px 4px #AAA;
-webkit-box-shadow: 3px 3px 4px #AAA;
box-shadow: 3px 3px 4px #AAA;
}
td, th {
border: 1px solid #D3D3D3;
padding: 4px 15px 4px 15px;
margin: 20px 15px 20px 15px;
}
th {
text-shadow: 2px 2px 2px white;
}
th {
border-bottom: 1px solid gray;
background-color: #DDDDFF;
}
em, .em {
font-weight: bold;
}</style></head><body><img class='logo' src='http://codenarc.github.io/CodeNarc/images/codenarc-logo.png' alt='CodeNarc' align='right'/><h1>CodeNarc Report</h1><div class='metadata'><table><tr><td class='em'>Report title:</td><td>Sample Project</td></tr><tr><td class='em'>Date:</td><td>Apr 7, 2021 9:49:11 PM</td></tr><tr><td class='em'>Generated with:</td><td><a href='https://www.codenarc.org'>CodeNarc v2.1.0</a></td></tr></table></div><div class='summary'><h2>Summary</h2><table><tr class='tableHeader'><th>Package</th><th>Total Files</th><th>Files with Violations</th><th>Priority 1</th><th>Priority 2</th><th>Priority 3</th></tr><tr><td class='allPackages'>All Packages</td><td class='number'>416</td><td class='number'>57</td><td class='priority1'>-</td><td class='priority2'>76</td><td class='priority3'>36</td></tr><tr><td><a href='#<Root>'><Root></a></td><td class='number'>9</td><td class='number'>4</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>14</td></tr><tr><td>basic</td><td class='number'>45</td><td class='number'>-</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>-</td></tr><tr><td>braces</td><td class='number'>4</td><td class='number'>-</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>-</td></tr><tr><td><a href='#comments'>comments</a></td><td class='number'>17</td><td class='number'>13</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>15</td></tr><tr><td>concurrency</td><td class='number'>26</td><td class='number'>-</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>-</td></tr><tr><td><a href='#convention'>convention</a></td><td class='number'>29</td><td class='number'>1</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>1</td></tr><tr><td><a href='#design'>design</a></td><td class='number'>26</td><td class='number'>3</td><td class='priority1'>-</td><td class='priority2'>1</td><td class='priority3'>2</td></tr><tr><td>dry</td><td class='number'>4</td><td class='number'>-</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>-</td></tr><tr><td>enhanced</td><td class='number'>1</td><td class='number'>-</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>-</td></tr><tr><td>exceptions</td><td class='number'>20</td><td class='number'>-</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>-</td></tr><tr><td><a href='#formatting'>formatting</a></td><td class='number'>38</td><td class='number'>14</td><td class='priority1'>-</td><td class='priority2'>26</td><td class='priority3'>2</td></tr><tr><td><a href='#generic'>generic</a></td><td class='number'>11</td><td class='number'>2</td><td class='priority1'>-</td><td class='priority2'>3</td><td class='priority3'>-</td></tr><tr><td><a href='#grails'>grails</a></td><td class='number'>12</td><td class='number'>2</td><td class='priority1'>-</td><td class='priority2'>3</td><td class='priority3'>-</td></tr><tr><td><a href='#groovyism'>groovyism</a></td><td class='number'>33</td><td class='number'>3</td><td class='priority1'>-</td><td class='priority2'>17</td><td class='priority3'>-</td></tr><tr><td><a href='#imports'>imports</a></td><td class='number'>7</td><td class='number'>1</td><td class='priority1'>-</td><td class='priority2'>1</td><td class='priority3'>-</td></tr><tr><td>jdbc</td><td class='number'>6</td><td class='number'>-</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>-</td></tr><tr><td>junit</td><td class='number'>25</td><td class='number'>-</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>-</td></tr><tr><td>logging</td><td class='number'>8</td><td class='number'>-</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>-</td></tr><tr><td><a href='#naming'>naming</a></td><td class='number'>16</td><td class='number'>1</td><td class='priority1'>-</td><td class='priority2'>1</td><td class='priority3'>-</td></tr><tr><td>security</td><td class='number'>10</td><td class='number'>-</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>-</td></tr><tr><td>serialization</td><td class='number'>4</td><td class='number'>-</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>-</td></tr><tr><td><a href='#size'>size</a></td><td class='number'>9</td><td class='number'>2</td><td class='priority1'>-</td><td class='priority2'>-</td><td class='priority3'>2</td></tr><tr><td><a href='#unnecessary'>unnecessary</a></td><td class='number'>47</td><td class='number'>6</td><td class='priority1'>-</td><td class='priority2'>14</td><td class='priority3'>-</td></tr><tr><td><a href='#unused'>unused</a></td><td class='number'>9</td><td class='number'>5</td><td class='priority1'>-</td><td class='priority2'>10</td><td class='priority3'>-</td></tr></table></div><div class='summary'><a name='<Root>'> </a><h2 class='packageHeader'>Package: <Root></h2></div><div class='summary'><h3 class='fileHeader'>➥ AbstractAstVisitorRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryObjectReferences'>UnnecessaryObjectReferences</a></td><td class='priority3'>3</td><td class='number'>184</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>rule.doNotApplyToClassNames = 'Xxx' // doNotApply = NO</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The code could be more concise by using a with() or identity() block</span></p></td></tr><tr><td><a href='#UnnecessaryObjectReferences'>UnnecessaryObjectReferences</a></td><td class='priority3'>3</td><td class='number'>187</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>rule.applyToClassNames = 'Xxx' // apply = NO</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The code could be more concise by using a with() or identity() block</span></p></td></tr><tr><td><a href='#UnnecessaryObjectReferences'>UnnecessaryObjectReferences</a></td><td class='priority3'>3</td><td class='number'>188</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>rule.doNotApplyToClassNames = 'Xxx' // doNotApply = NO</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The code could be more concise by using a with() or identity() block</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ AbstractEnhanceableAstVisitorRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#MisorderedStaticImports'>MisorderedStaticImports</a></td><td class='priority3'>3</td><td class='number'>22</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>import static org.codenarc.rule.AbstractEnhanceableAstVi..TEM_PROPERTY</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Static imports should appear before normal imports</span></p></td></tr><tr><td><a href='#MisorderedStaticImports'>MisorderedStaticImports</a></td><td class='priority3'>3</td><td class='number'>23</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>import static org.codenarc.source.SourceCode.DEFAULT_COMPILER_PHASE</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Static imports should appear before normal imports</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ AbstractRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryObjectReferences'>UnnecessaryObjectReferences</a></td><td class='priority3'>3</td><td class='number'>137</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>rule.doNotApplyToFilesMatching = NO_MATCH // doNotApply = NO</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The code could be more concise by using a with() or identity() block</span></p></td></tr><tr><td><a href='#UnnecessaryObjectReferences'>UnnecessaryObjectReferences</a></td><td class='priority3'>3</td><td class='number'>140</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>rule.applyToFilesMatching = NO_MATCH // apply = NO</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The code could be more concise by using a with() or identity() block</span></p></td></tr><tr><td><a href='#UnnecessaryObjectReferences'>UnnecessaryObjectReferences</a></td><td class='priority3'>3</td><td class='number'>141</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>rule.doNotApplyToFilesMatching = NO_MATCH // doNotApply = NO</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The code could be more concise by using a with() or identity() block</span></p></td></tr><tr><td><a href='#UnnecessaryObjectReferences'>UnnecessaryObjectReferences</a></td><td class='priority3'>3</td><td class='number'>177</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>rule.applyToFileNames = 'org/codenarc/MyOtherTest.groovy'</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The code could be more concise by using a with() or identity() block</span></p></td></tr><tr><td><a href='#UnnecessaryObjectReferences'>UnnecessaryObjectReferences</a></td><td class='priority3'>3</td><td class='number'>225</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>rule.doNotApplyToFileNames = 'Xxx.groovy' // doNotApply = NO</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The code could be more concise by using a with() or identity() block</span></p></td></tr><tr><td><a href='#UnnecessaryObjectReferences'>UnnecessaryObjectReferences</a></td><td class='priority3'>3</td><td class='number'>228</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>rule.applyToFileNames = 'Xxx.groovy' // apply = NO</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The code could be more concise by using a with() or identity() block</span></p></td></tr><tr><td><a href='#UnnecessaryObjectReferences'>UnnecessaryObjectReferences</a></td><td class='priority3'>3</td><td class='number'>229</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>rule.doNotApplyToFileNames = 'Xxx.groovy' // doNotApply = NO</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The code could be more concise by using a with() or identity() block</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ InlineViolationsParserTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#MisorderedStaticImports'>MisorderedStaticImports</a></td><td class='priority3'>3</td><td class='number'>20</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>import static org.codenarc.rule.InlineViolationsParser.inlineViolation</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Static imports should appear before normal imports</span></p></td></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>199</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return [lineNumber: lineNumber, sourceLineText: sourceLi..messageText]</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><a name='comments'> </a><h2 class='packageHeader'>Package: comments</h2></div><div class='summary'><h3 class='fileHeader'>➥ AbstractJavadocEmptyTagRuleTestCase.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>53</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return rule.name</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>56</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return "The javadoc ${getTag()} tag is empty"</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ AbstractJavadocMissingDescriptionRuleTestCase.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>51</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return rule.name</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>54</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return "The description for the javadoc ${getTag()} tag is missing"</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ JavadocEmptyAuthorTagRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return '@author'</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ JavadocEmptyExceptionTagRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return '@exception'</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ JavadocEmptyParamTagRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return '@param'</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ JavadocEmptyReturnTagRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return '@return'</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ JavadocEmptySeeTagRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return '@see'</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ JavadocEmptySinceTagRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return '@since'</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ JavadocEmptyThrowsTagRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return '@throws'</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ JavadocEmptyVersionTagRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return '@version'</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ JavadocMissingExceptionDescriptionRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return '@exception'</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ JavadocMissingParamDescriptionRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return '@param'</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ JavadocMissingThrowsDescriptionRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return '@throws'</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><a name='convention'> </a><h2 class='packageHeader'>Package: convention</h2></div><div class='summary'><h3 class='fileHeader'>➥ CompileStaticRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>34</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return new CompileStaticRule()</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><a name='design'> </a><h2 class='packageHeader'>Package: design</h2></div><div class='summary'><h3 class='fileHeader'>➥ NestedForLoopRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>106</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return inlineViolation('Nested for loop')</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ OptionalCollectionReturnTypeRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>128</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return "The method $methodName in class MyClass returns .. collection"</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ PrivateFieldCouldBeFinalRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#MethodCount'>MethodCount</a></td><td class='priority2'>2</td><td class='number'>26</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>class PrivateFieldCouldBeFinalRuleTest extends AbstractR..FinalRule> {</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Class org.codenarc.rule.design.PrivateFieldCouldBeFinalRuleTest has 34 methods</span></p></td></tr></table></div><div class='summary'><a name='formatting'> </a><h2 class='packageHeader'>Package: formatting</h2></div><div class='summary'><h3 class='fileHeader'>➥ BracesForForLoopRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>101</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
for(String name=${SomeClass.SOME_CONSTANT}; name==null;) // And what about {}
{
doStuff()
}
' contains a GString-type expression: '${SomeClass.SOME_CONSTANT}; name==null;) // And what about {}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ BracesForIfElseRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>59</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
if (someContainer."${SomeClass.SOME_CONSTANT}" != null) // And what about {}
{
doStuff()
}
' contains a GString-type expression: '${SomeClass.SOME_CONSTANT}" != null) // And what about {}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ BracesForMethodRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#MethodCount'>MethodCount</a></td><td class='priority2'>2</td><td class='number'>28</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>class BracesForMethodRuleTest extends AbstractRuleTestCa..ethodRule> {</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Class org.codenarc.rule.formatting.BracesForMethodRuleTest has 32 methods</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>356</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
int size(String name = "${SomeClass.SOME_CONSTANT}")
{
return 99
}
}
' contains a GString-type expression: '${SomeClass.SOME_CONSTANT}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ ClassEndsWithBlankLineRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#MethodCount'>MethodCount</a></td><td class='priority2'>2</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>class ClassEndsWithBlankLineRuleTest extends AbstractRul..kLineRule> {</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Class org.codenarc.rule.formatting.ClassEndsWithBlankLineRuleTest has 33 methods</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ ClassStartsWithBlankLineRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#MethodCount'>MethodCount</a></td><td class='priority2'>2</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>class ClassStartsWithBlankLineRuleTest extends AbstractR..kLineRule> {</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Class org.codenarc.rule.formatting.ClassStartsWithBlankLineRuleTest has 43 methods</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ IndentationRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#MethodCount'>MethodCount</a></td><td class='priority2'>2</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>class IndentationRuleTest extends AbstractRuleTestCase<I..ationRule> {</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Class org.codenarc.rule.formatting.IndentationRuleTest has 52 methods</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>607</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
|class MyClass {
| private void execute() {
| try {
| executeWithArgs(args)
| }
| catch(Throwable t) {
| println "ERROR: ${t.message}"
| t.printStackTrace()
| }
| finally {
| closeResources()
| }
| }
| private void executeOtherOne() {
| try {
| executeWithArgs(args)
| } catch(Throwable t) {
| t.printStackTrace()
| } finally {
| closeResources()
| }
| }
|}
' contains a GString-type expression: '${t.message}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>897</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
|project.files(project.configurations.scaconfig.files.findAll { File it -> it.name.endsWith '.aar' }.collect { File it ->
| MessageDigest sha1 = MessageDigest.getInstance('SHA1')
| String inputFile = 'COMMAND=PREPARE_LIBRARY\n' +
| "FILE_PATH=${it.absolutePath}\n"
| String hash = new BigInteger(1, sha1.digest(inputFile.bytes)).toString(16)
| cacheDir + hash + File.separator + 'output/jars/classes.jar'
|}).asFileTree
' contains a GString-type expression: '${it.absolutePath}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>911</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
|"${if (true) 'content' else ''}"
' contains a GString-type expression: '${if (true) 'content' else ''}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>919</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
|package com.sample
|
|trait RegressionTest {
|
| String callStackPath = "src/test/resources/callstacks/"
|
| /**
| * Checks the current callstack is the same as the reference callstack.
| * The reference callstack can be updated into a txt file in the callStackPath
| *
| * Pattern: <RegressionTest.callStackPath>/<ClassTestSimpleName><_subname>.txt
| * @param subname optional subname, used in the reference callstack filename
| */
| void testNonRegression(String subname = '') {
| String targetFileName = "${callStackPath}${this.class.simpleName}"
| if (subname) {
| targetFileName += "_${subname}"
| }
| RegressionTestHelper.testNonRegression(helper, targetFileName)
| }
|}
' contains a GString-type expression: '${callStackPath}${this.class.simpleName}'</span></p></td></tr><tr><td><a href='#ClassSize'>ClassSize</a></td><td class='priority3'>3</td><td class='number'>27</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Class "IndentationRuleTest" is 1037 lines</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ IndentationRule_MethodChainingTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>82</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
|buildFileList()
| .collect { File it ->
| MessageDigest sha1 = MessageDigest.getInstance('SHA1')
| String inputFile = 'COMMAND=PREPARE_LIBRARY\n' +
| "FILE_PATH=${it.absolutePath}\n"
| cacheDir + File.separator + inputFile + sha1
| }
| .each { name ->
| println name
| }
|println "done"
|
|list2.collect { item ->
| item.name
|}.each { name -> println name }
|
|otherList.collect { item -> item.name }.each { name -> println name }
|
|if (expr instanceof ConstructorCallExpression || expr instanceof CastExpression) {
| [Map, Iterable, List, Collection, ArrayList, Set, HashSet].findAll {
| AstUtil.classNodeImplementsType(expr.type, it)
| }.each {
| callbackFunction()
| }
|}
' contains a GString-type expression: '${it.absolutePath}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ MissingBlankLineBeforeAnnotatedFieldRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>111</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
private @Autowired DataSource dataSource
private @Value('${name}') String name
}
' contains a GString-type expression: '${name}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ SpaceAfterClosingBraceRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>38</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
def myMethod() {
def closure = { }
if (true) { }
while(ready) { }
try {
} catch(Exception e) {
} finally { }
for(int i=0; i<10; i++) { }
for(String name in names) { }
for(String name: names) { }
if (count > this."maxPriority${priority}Violations") { }
while (count > this."maxPriority${priority}Violations") { }
}
MyClass() {
this(classNames)
} // ok
static void reset() { violationCounts = [1:0, 2:0, 3:0] }
void doStuff() { println 9 }
}
interface MyInterface { }
enum MyEnum { OK, BAD }
' contains a GString-type expression: '${priority}Violations") { }'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>304</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>assertNoViolations('''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
def foo = 1
"I am a ${ -> foo }"
' contains a GString-type expression: '${ -> foo }'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>312</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>assertNoViolations('''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
def foo = 1
"I am a ${ -> foo }0"
' contains a GString-type expression: '${ -> foo }'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ SpaceAfterCommaRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>53</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
def template() {
return {
td(getResourceBundleString('htmlReport.summary.allPackages'), class:'allPackages')
td {
a(pathName, href:"#${pathName}")
}
}
}
}
' contains a GString-type expression: '${pathName}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ SpaceAfterOpeningBraceRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>40</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
def myMethod() {
def closure = { }
if (true) { }
while(ready) { }
try {
} catch(Exception e) {
} finally { }
for(int i=0; i<10; i++) { }
for(String name in names) { }
for(String name: names) { }
if (count > this."maxPriority${priority}Violations") { }
while (count > this."maxPriority${priority}Violations") { }
}
MyClass() {
this(classNames)
}
MyClass(String s) { }
MyClass(@Annotation('${prop}') String s) {
}
MyClass(Date date) { // comment
this(classNames)
}
MyClass(Object object) { /* comment */ }
}
interface MyInterface { }
enum MyEnum { OK, BAD }
trait MyTrait { }
' contains a GString-type expression: '${priority}Violations") { }'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>87</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
def myMethod() {
def closure = {}
if (true) {}
while(ready) {}
try {
} catch(Exception e) {
} finally {}
for(int i=0; i<10; i++) {}
for(String name in names) {}
for(String name: names) {}
if (count > this."maxPriority${priority}Violations") {}
while (count > this."maxPriority${priority}Violations") {}
}
void doStuff2() {}
MyClass() {}
MyClass(@Annotation('${prop}') String s) {}
}
interface MyInterface2 {}
' contains a GString-type expression: '${priority}Violations") {}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>181</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
MyClass() {int count }
MyClass() {s = '{"json": true}' }
MyClass(@Annotation('${prop}') String s) {println 123 }
}
' contains a GString-type expression: '${prop}') String s) {println 123 }'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>192</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>[line:5, source:'MyClass(@Annotation(\'${prop}\') String..s MyClass'])</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String 'MyClass(@Annotation('${prop}') String s) {println 123 }' contains a GString-type expression: '${prop}') String s) {println 123 }'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>310</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
String s
MyClass() { s = '{"json": true}' }
MyClass(@Annotation('${prop}') String s) { println 123 }
}
' contains a GString-type expression: '${prop}') String s) { println 123 }'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ SpaceAroundMapEntryColonRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>156</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return inlineViolation("The colon for the literal Map en..className" +</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ SpaceBeforeClosingBraceRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>39</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
def myMethod() {
def closure = { }
if (true) { }
while(ready) { }
try {
} catch(Exception e) {
} finally { }
for(int i=0; i<10; i++) { }
for(String name in names) { }
for(String name: names) { }
if (count > this."maxPriority${priority}Violations") { }
while (count > this."maxPriority${priority}Violations") { }
}
MyClass() {
this(classNames)
}
static void reset() { violationCounts = [1:0, 2:0, 3:0] }
void doStuff() { println 9 }
}
interface MyInterface { }
enum MyEnum { OK, BAD }
' contains a GString-type expression: '${priority}Violations") { }'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>80</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
def myMethod() {
def closure = {}
if (true) {}
while(ready) {}
try {
} catch(Exception e) {
} finally {}
for(int i=0; i<10; i++) {}
for(String name in names) {}
for(String name: names) {}
if (count > this."maxPriority${priority}Violations") {}
while (count > this."maxPriority${priority}Violations") {}
}
void doStuff2() {}
}
interface MyInterface2 {}
' contains a GString-type expression: '${priority}Violations") {}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ SpaceBeforeOpeningBraceRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>38</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
def myMethod() {
def closure = { }
if (true) { }
while(ready) { }
try {
} catch(Exception e) {
} finally { }
for(int i=0; i<10; i++) { }
for(String name in names) { }
for(String name: names) { }
if (count > this."maxPriority${priority}Violations") { }
while (count > this."maxPriority${priority}Violations") { }
}
MyClass() {
this(classNames)
}
}
interface MyInterface { }
enum MyEnum { OK, BAD }
trait MyTrait { }
' contains a GString-type expression: '${priority}Violations") { }'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>262</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>assertNoViolations('''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
def foo = 1
"I am a ${ -> foo }"
' contains a GString-type expression: '${ -> foo }'</span></p></td></tr></table></div><div class='summary'><a name='generic'> </a><h2 class='packageHeader'>Package: generic</h2></div><div class='summary'><h3 class='fileHeader'>➥ IllegalPackageReferenceRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>64</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
if (value.class == org.bad.BadClass) { }
println "isClosure=${value instanceof org.bad.OtherClass}"
def count = org.bad.Helper.getCount()
' contains a GString-type expression: '${value instanceof org.bad.OtherClass}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>72</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>[line:3, source:'println "isClosure=${value instanceof o..:'org.bad'],</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String 'println "isClosure=${value instanceof org.bad.OtherClass}"' contains a GString-type expression: '${value instanceof org.bad.OtherClass}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ StatelessClassRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>84</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
@Value('${org.codenarc.test}')
BigDecimal depositAmount
}
' contains a GString-type expression: '${org.codenarc.test}'</span></p></td></tr></table></div><div class='summary'><a name='grails'> </a><h2 class='packageHeader'>Package: grails</h2></div><div class='summary'><h3 class='fileHeader'>➥ GrailsMassAssignmentRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>36</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class Person {
String name
Boolean isAdmin
}
def bindingMap = [name: 'John', isAdmin: true]
def person = new Person()
def p2 = new Person("It is currently ${ new Date() }")
def p3 = new Person(bindingMap)
person.name = bindingMap['name']
person.isAdmin = bindingMap.isAdmin
person.properties = "It is currently ${ new Date() }"
' contains a GString-type expression: '${ new Date() }'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ GrailsServletContextReferenceRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>78</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
def mySession = servletContext
def edit = {
println "amount=${servletContext.amount}"
}
}
' contains a GString-type expression: '${servletContext.amount}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>87</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>assertTwoViolations(SOURCE, 3, 'def mySession = servletC..t.amount}"')</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String 'println "amount=${servletContext.amount}"' contains a GString-type expression: '${servletContext.amount}'</span></p></td></tr></table></div><div class='summary'><a name='groovyism'> </a><h2 class='packageHeader'>Package: groovyism</h2></div><div class='summary'><h3 class='fileHeader'>➥ ClosureAsLastMethodParameterRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>248</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
new Exception("${it.orElseThrow { new AssertionError() }}")
' contains a GString-type expression: '${it.orElseThrow { new AssertionError() }}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ GStringAsMapKeyRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>44</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
Map map = ["${ someRef }" : 'invalid' ]
' contains a GString-type expression: '${ someRef }'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>48</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>2, '["${ someRef }" :')</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '["${ someRef }" :' contains a GString-type expression: '${ someRef }'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ GStringExpressionWithinStringRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>49</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class SomeClass {
@SomeAnnotationOnField('${sample.property1}')
String sampleProperty
@SomeAnnotationOnMethod('${sample.property2}')
void method() {
}
}
' contains a GString-type expression: '${sample.property1}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>64</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
@SomeAnnotationOnClass('${sample.property1}')
class SomeClass {
@SomeAnnotationOnField('${sample.property2}')
String sampleProperty
@SomeAnnotationOnMethod('${sample.property3}')
void method() {
}
}
' contains a GString-type expression: '${sample.property1}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>80</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
@SomeAnnotationOnClass(attribute='${sample.property1}',
nested=[@NestedAnnotation('${sample.property2}'),
@NestedAnnotation('${sample.property3}')],
someOtherAttribute='${sample.property4}')
class SomeClass {
}
' contains a GString-type expression: '${sample.property1}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>93</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
@SomeAnnotationOnClass(attribute=['${sample.property1}', '${sample.property2}'])
class SomeClass {
}
' contains a GString-type expression: '${sample.property1}', '${sample.property2}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>103</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
def valueToBeReplaced = '123'
def str1 = "123"
def str2 = "abc def ghi"
def str3 = "abc ${count}"
def str4 = "abc $count }"
def str5 = "abc {123}"
def str6 = "abc ${}"
def str7 = "total: ${count * 25}"
def str8 = "$valueToBeReplaced $valueNotToBeReplaced"
' contains a GString-type expression: '${count}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>119</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
def "plugin does not apply idea plugin"() {
given:
buildScript << """
task $testTaskName {
doLast {
println "Has idea plugin: \${project.plugins.hasPlugin(IdeaPlugin)}"
}
}
"""
expect:
runTask(testTaskName).output.contains('Has idea plugin: false')
where:
testTaskName = 'hasIdeaPlugin'
}
' contains a GString-type expression: '${project.plugins.hasPlugin(IdeaPlugin)}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>142</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
def str1 = 'total: ${count}'
def str2 = 'average: ${total / count}'
' contains a GString-type expression: '${count}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>147</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>[line:2, source:"def str1 = 'total: \${count}'", message..{count}\''],</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String 'def str1 = 'total: ${count}'' contains a GString-type expression: '${count}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>147</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>[line:2, source:"def str1 = 'total: \${count}'", message..{count}\''],</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String ''${count}'' contains a GString-type expression: '${count}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>148</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>[line:3, source:"def str2 = 'average: \${total / count}'.. count}\''])</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String 'def str2 = 'average: ${total / count}'' contains a GString-type expression: '${total / count}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>148</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>[line:3, source:"def str2 = 'average: \${total / count}'.. count}\''])</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String ''${total / count}'' contains a GString-type expression: '${total / count}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>153</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class SomeClass {
@SomeAnnotationOnMethod('${sample.property}')
void method() {
def str1 = 'total: ${count}'
}
}
' contains a GString-type expression: '${sample.property}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>161</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>assertSingleViolation(SOURCE, 5, "def str1 = 'total: \${..${count}\'')</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String 'def str1 = 'total: ${count}'' contains a GString-type expression: '${count}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>161</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>assertSingleViolation(SOURCE, 5, "def str1 = 'total: \${..${count}\'')</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String ''${count}'' contains a GString-type expression: '${count}'</span></p></td></tr></table></div><div class='summary'><a name='imports'> </a><h2 class='packageHeader'>Package: imports</h2></div><div class='summary'><h3 class='fileHeader'>➥ UnusedImportRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>192</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
import test.TestData1
import test.TestData2
import test.TestData3
import test.TestData4
import test.TestData5
import test.TestData6
import test.TestData7
import test.TestData8
import test.TestData9
import test.TestData10
import test.TestData11
import test.TestData12
import test.TestData13
import test.TestData14
import test.TestData15
def GSTRING1 = " ${TestData1.GOOD_XML}"
def GSTRING2 = " $TestData2.XML"
def MAP1 = [(TestData3):123]
def MAP2 = [abc:TestData4]
def MAP3 = [abc:TestData5, ddd:123]
def LIST = [TestData6,TestData7]
def OPERATORS1 = 0+TestData8.VALUE-TestData9.VALUE
def OPERATORS2 = 9*TestData10.VALUE/TestData11.VALUE
def OPERATORS3 = 64&TestData12.VALUE|TestData13.VALUE^TestData14.VALUE
def OPERATORS4 = !TestData15.VALUE
' contains a GString-type expression: '${TestData1.GOOD_XML}'</span></p></td></tr></table></div><div class='summary'><a name='naming'> </a><h2 class='packageHeader'>Package: naming</h2></div><div class='summary'><h3 class='fileHeader'>➥ FieldNameRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#MethodCount'>MethodCount</a></td><td class='priority2'>2</td><td class='number'>28</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>class FieldNameRuleTest extends AbstractRuleTestCase<FieldNameRule> {</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Class org.codenarc.rule.naming.FieldNameRuleTest has 32 methods</span></p></td></tr></table></div><div class='summary'><a name='size'> </a><h2 class='packageHeader'>Package: size</h2></div><div class='summary'><h3 class='fileHeader'>➥ GMetricsSourceCodeAdapterTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#MisorderedStaticImports'>MisorderedStaticImports</a></td><td class='priority3'>3</td><td class='number'>22</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>import static org.codenarc.test.TestUtil.shouldFailWithM..geContaining</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Static imports should appear before normal imports</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ ParameterCountRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#UnnecessaryReturnKeyword'>UnnecessaryReturnKeyword</a></td><td class='priority3'>3</td><td class='number'>252</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>return inlineViolation("Number of parameters in ${name} ..ameters}).")</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The return keyword is not needed and can be removed</span></p></td></tr></table></div><div class='summary'><a name='unnecessary'> </a><h2 class='packageHeader'>Package: unnecessary</h2></div><div class='summary'><h3 class='fileHeader'>➥ ConsecutiveStringConcatenationRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>65</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
def b = "$Hello" + 'World' // should be "${Hello}World"
' contains a GString-type expression: '${Hello}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>73</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
def c = 'Hello' + "$World" // should be "Hello${World}"
' contains a GString-type expression: '${World}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ UnnecessaryGStringRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>36</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
def docFile = "docs/codenarc-rules-${ruleSetName}.apt"
' contains a GString-type expression: '${ruleSetName}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ UnnecessaryGetterRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>180</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
Mock {
getSomeData()
}
Stub(1,2,3) {
getData2()
}
"${'Stub'}"(MyClass) {
getData3()
}
def closure = { getData4() }
Mock({ getData5() }, 1234) // 2nd param is not a Closure
Spy {
getMoreData()
}
' contains a GString-type expression: '${'Stub'}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ UnnecessaryPackageReferenceRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>66</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
if (value.class == java.math.BigDecimal) { }
println "isClosure=${value instanceof groovy.lang.Closure}"
def processors = java.lang.Runtime.availableProcessors()
' contains a GString-type expression: '${value instanceof groovy.lang.Closure}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>73</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>[line:3, source:'println "isClosure=${value instanceof g..oovy.lang'],</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String 'println "isClosure=${value instanceof groovy.lang.Closure}"' contains a GString-type expression: '${value instanceof groovy.lang.Closure}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ UnnecessarySetterRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>69</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
if (!file.setExecutable(true)) {
throw new Exception("Cannot set ${file} as executable")
}
def count = x.setCount(92)
' contains a GString-type expression: '${file}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ UnnecessaryToStringRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>67</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
def name = "Joe" + new Date().toString()
void run() {
Object object = 1
def string = 'some string' + object.toString()
def withinGString = "processing: ${'prefix' + object.toString()}"
def bigString = 'some string' + new Date() + object.toString() // not a violation; known limitation
def other = 123 + object.toString().toInteger() // not a violation
}
}
' contains a GString-type expression: '${'prefix' + object.toString()}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>84</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>[line:8, source:'def withinGString = "processing: ${\'pr..necessary'])</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String 'def withinGString = "processing: ${'prefix' + object.toString()}"' contains a GString-type expression: '${'prefix' + object.toString()}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>89</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
def string = "some string${123L.toString()} or ${123} or ${'ABC'} or ${new Date().toString()}"
def string2 = """
processing: ${123L.toString()}
processing: ${new Date().toString()}
"""
' contains a GString-type expression: '${123L.toString()} or ${123} or ${'ABC'} or ${new Date().toString()}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>97</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>[line:2, source:'def string = "some string${123L.toStrin..necessary'],</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String 'def string = "some string${123L.toString()} or ${123} or ${'ABC'} or ${new Date().toString()}"' contains a GString-type expression: '${123L.toString()} or ${123} or ${'ABC'} or ${new Date().toString()}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>98</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>[line:2, source:'def string = "some string${123L.toStrin..necessary'],</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String 'def string = "some string${123L.toString()} or ${123} or ${'ABC'} or ${new Date().toString()}"' contains a GString-type expression: '${123L.toString()} or ${123} or ${'ABC'} or ${new Date().toString()}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>99</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>[line:4, source:'processing: ${123L.toString()}', messag..necessary'],</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String 'processing: ${123L.toString()}' contains a GString-type expression: '${123L.toString()}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>100</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>[line:5, source:'processing: ${new Date().toString()}', ..nnecessary']</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String 'processing: ${new Date().toString()}' contains a GString-type expression: '${new Date().toString()}'</span></p></td></tr></table></div><div class='summary'><a name='unused'> </a><h2 class='packageHeader'>Package: unused</h2></div><div class='summary'><h3 class='fileHeader'>➥ AbstractUnusedPrivateFieldRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>160</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
private int count
def other = this."${'count'}"
}
' contains a GString-type expression: '${'count'}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>171</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
private int count
def varName = "count"
def other = this."${varName}" // can't see this
}
' contains a GString-type expression: '${varName}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ UnusedMethodParameterRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>150</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
MyClass() { }
MyClass(String id) { println id }
String myMethod1(String id, int value) { doSomething(value); return id }
void myMethod2(int value) { def x = value }
def myMethod3(Date startDate) { return "${startDate}" }
def myMethod4(Date startDate) {
return new Object() {
def x = startDate
}
}
def myMethod5(Date startDate) {
return new Object() {
String toString() { return startDate }
}
}
}
' contains a GString-type expression: '${startDate}" }'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ UnusedPrivateMethodParameterRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>126</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
private String myMethod1(String id, int value) { doSomething(value); return id }
private void myMethod2(int value) { def x = value }
private def myMethod3(Date startDate) { return "${startDate}" }
private def myMethod4(Date startDate) {
return new Object() {
def x = startDate
}
}
private def myMethod5(Date startDate) {
return new Object() {
String toString() { return startDate }
}
}
}
' contains a GString-type expression: '${startDate}" }'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ UnusedPrivateMethodRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#MethodCount'>MethodCount</a></td><td class='priority2'>2</td><td class='number'>26</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>class UnusedPrivateMethodRuleTest extends AbstractRuleTe..ethodRule> {</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Class org.codenarc.rule.unused.UnusedPrivateMethodRuleTest has 36 methods</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>354</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
private int countStuff() { return 99 }
int somePublicMethod() { }
def abc = 'abc'
private String getName() { 'abc' }
private getPrice() { 0.0 }
def doStuff() {
def count = countStuff()
def newName = this.getName()
}
def myClosure = { println "price is ${getPrice()}" }
}
' contains a GString-type expression: '${getPrice()}" }'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>423</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
static int getTotal() {
println "total=${MyClass.countStuff()}"
}
private static int countStuff() { }
}
' contains a GString-type expression: '${MyClass.countStuff()}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>436</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
private int countStuff() { }
def other = this."${countStuff}"()
}
' contains a GString-type expression: '${countStuff}'</span></p></td></tr><tr><td><a href='#GStringExpressionWithinString'>GStringExpressionWithinString</a></td><td class='priority2'>2</td><td class='number'>458</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>final SOURCE = '''</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>The String '
class MyClass {
private int countStuff() { }
def varName = "countStuff"
def other = this."${varName}"() // can't see this
}
' contains a GString-type expression: '${varName}'</span></p></td></tr></table></div><div class='summary'><h3 class='fileHeader'>➥ UnusedVariableRuleTest.groovy</h3><table border='1'><tr class='tableHeader'><th>Rule Name</th><th>Priority</th><th>Line #</th><th>Source Line / Message</th></tr><tr><td><a href='#MethodCount'>MethodCount</a></td><td class='priority2'>2</td><td class='number'>26</td><td><p class='violationInfo'><span class='violationInfoPrefix'>[SRC]</span><span class='sourceCode'>class UnusedVariableRuleTest extends AbstractRuleTestCas..iableRule> {</span></p><p class='violationInfo'><span class='violationInfoPrefix'>[MSG]</span><span class='violationMessage'>Class org.codenarc.rule.unused.UnusedVariableRuleTest has 35 methods</span></p></td></tr></table></div><div class='summary'><h2>Rule Descriptions</h2><table border='1'><tr class='tableHeader'><th class='ruleDescriptions'>#</th><th class='ruleDescriptions'>Rule Name</th><th class='ruleDescriptions'>Description</th></tr><tr class='ruleDescriptions'><td><a name='AbcMetric'></a><span class='ruleIndex'>1</span></td><td class='ruleName priority2'>AbcMetric</td><td>Checks the ABC size metric for methods/classes. A method (or "closure field") with an ABC score greater than the <em>maxMethodAbcScore</em> property (60) causes a violation. Likewise, a class that has an (average method) ABC score greater than the <em>maxClassAverageMethodAbcScore</em> property (60) causes a violation.</td></tr><tr class='ruleDescriptions'><td><a name='AddEmptyString'></a><span class='ruleIndex'>2</span></td><td class='ruleName priority2'>AddEmptyString</td><td>Finds empty string literals which are being added. This is an inefficient way to convert any type to a String.</td></tr><tr class='ruleDescriptions'><td><a name='AssertWithinFinallyBlock'></a><span class='ruleIndex'>3</span></td><td class='ruleName priority2'>AssertWithinFinallyBlock</td><td>Checks for <em>assert</em> statements within a <em>finally</em> block. An <em>assert</em> can throw an exception, hiding the original exception, if there is one.</td></tr><tr class='ruleDescriptions'><td><a name='AssignCollectionSort'></a><span class='ruleIndex'>4</span></td><td class='ruleName priority2'>AssignCollectionSort</td><td>The Collections.sort() method mutates the list and returns the list as a value. If you are assigning the result of sort() to a variable, then you probably don't realize that you're also modifying the original list as well. This is frequently the cause of subtle bugs.</td></tr><tr class='ruleDescriptions'><td><a name='AssignCollectionUnique'></a><span class='ruleIndex'>5</span></td><td class='ruleName priority2'>AssignCollectionUnique</td><td>The Collections.unique() method mutates the list and returns the list as a value. If you are assigning the result of unique() to a variable, then you probably don't realize that you're also modifying the original list as well. This is frequently the cause of subtle bugs.</td></tr><tr class='ruleDescriptions'><td><a name='AssignmentInConditional'></a><span class='ruleIndex'>6</span></td><td class='ruleName priority2'>AssignmentInConditional</td><td>An assignment operator (=) was used in a conditional test. This is usually a typo, and the comparison operator (==) was intended.</td></tr><tr class='ruleDescriptions'><td><a name='BigDecimalInstantiation'></a><span class='ruleIndex'>7</span></td><td class='ruleName priority2'>BigDecimalInstantiation</td><td>Checks for calls to the <em>BigDecimal</em> constructors that take a <em>double</em> parameter, which may result in an unexpected <em>BigDecimal</em> value.</td></tr><tr class='ruleDescriptions'><td><a name='BitwiseOperatorInConditional'></a><span class='ruleIndex'>8</span></td><td class='ruleName priority2'>BitwiseOperatorInConditional</td><td>Checks for bitwise operations in conditionals, if you need to do a bitwise operation then it is best practice to extract a temp variable.</td></tr><tr class='ruleDescriptions'><td><a name='BooleanGetBoolean'></a><span class='ruleIndex'>9</span></td><td class='ruleName priority2'>BooleanGetBoolean</td><td>This rule catches usages of java.lang.Boolean.getBoolean(String) which reads a boolean from the System properties. It is often mistakenly used to attempt to read user input or parse a String into a boolean. It is a poor piece of API to use; replace it with System.properties['prop'].</td></tr><tr class='ruleDescriptions'><td><a name='BrokenNullCheck'></a><span class='ruleIndex'>10</span></td><td class='ruleName priority2'>BrokenNullCheck</td><td>Looks for faulty checks for null that can cause a <em>NullPointerException</em>.</td></tr><tr class='ruleDescriptions'><td><a name='BrokenOddnessCheck'></a><span class='ruleIndex'>11</span></td><td class='ruleName priority2'>BrokenOddnessCheck</td><td>The code uses x % 2 == 1 to check to see if a value is odd, but this won't work for negative numbers (e.g., (-5) % 2 == -1). If this code is intending to check for oddness, consider using x & 1 == 1, or x % 2 != 0.</td></tr><tr class='ruleDescriptions'><td><a name='ClassForName'></a><span class='ruleIndex'>12</span></td><td class='ruleName priority2'>ClassForName</td><td>Using Class.forName(...) is a common way to add dynamic behavior to a system. However, using this method can cause resource leaks because the classes can be pinned in memory for long periods of time.</td></tr><tr class='ruleDescriptions'><td><a name='ClassSize'></a><span class='ruleIndex'>13</span></td><td class='ruleName priority3'>ClassSize</td><td>Checks if the size of a class exceeds the number of lines specified by the <em>maxLines</em> property (1000).</td></tr><tr class='ruleDescriptions'><td><a name='ClosureAsLastMethodParameter'></a><span class='ruleIndex'>14</span></td><td class='ruleName priority3'>ClosureAsLastMethodParameter</td><td>If a method is called and the last parameter is an inline closure then it can be declared outside of the method call brackets.</td></tr><tr class='ruleDescriptions'><td><a name='CollectAllIsDeprecated'></a><span class='ruleIndex'>15</span></td><td class='ruleName priority2'>CollectAllIsDeprecated</td><td>collectAll{} is deprecated since Groovy 1.8.1. Use collectNested instead{}.</td></tr><tr class='ruleDescriptions'><td><a name='ComparisonOfTwoConstants'></a><span class='ruleIndex'>16</span></td><td class='ruleName priority2'>ComparisonOfTwoConstants</td><td>Checks for expressions where a comparison operator or <em>equals()</em> or <em>compareTo()</em> is used to compare two constants to each other or two literals that contain only constant values., e.g.: <em>23 == 67, Boolean.FALSE != false, 0.17 <= 0.99, "abc" > "ddd", [a:1] <=> [a:2], [1,2].equals([3,4]) or [a:false, b:true].compareTo(['a':34.5, b:Boolean.TRUE]</em>.</td></tr><tr class='ruleDescriptions'><td><a name='ComparisonWithSelf'></a><span class='ruleIndex'>17</span></td><td class='ruleName priority2'>ComparisonWithSelf</td><td>Checks for expressions where a comparison operator or <em>equals()</em> or <em>compareTo()</em> is used to compare a variable to itself, e.g.: <em>x == x, x != x, x <=> x, x < x, x =>= x, x.equals(x) or x.compareTo(x)</em>, where <em>x</em> is a variable.</td></tr><tr class='ruleDescriptions'><td><a name='ConfusingMultipleReturns'></a><span class='ruleIndex'>18</span></td><td class='ruleName priority2'>ConfusingMultipleReturns</td><td>Multiple return values can be used to set several variables at once. To use multiple return values, the left hand side of the assignment must be enclosed in parenthesis. If not, then you are not using multiple return values, you're only assigning the last element.</td></tr><tr class='ruleDescriptions'><td><a name='ConsecutiveLiteralAppends'></a><span class='ruleIndex'>19</span></td><td class='ruleName priority2'>ConsecutiveLiteralAppends</td><td>Violations occur when method calls to append(Object) are chained together with literals as parameters. The chained calls can be joined into one invocation.</td></tr><tr class='ruleDescriptions'><td><a name='ConsecutiveStringConcatenation'></a><span class='ruleIndex'>20</span></td><td class='ruleName priority3'>ConsecutiveStringConcatenation</td><td>Catches concatenation of two string literals on the same line. These can safely by joined.</td></tr><tr class='ruleDescriptions'><td><a name='ConstantAssertExpression'></a><span class='ruleIndex'>21</span></td><td class='ruleName priority3'>ConstantAssertExpression</td><td>Checks for <em>assert</em> statements where the assert boolean condition expression is a constant or literal value.</td></tr><tr class='ruleDescriptions'><td><a name='ConstantIfExpression'></a><span class='ruleIndex'>22</span></td><td class='ruleName priority2'>ConstantIfExpression</td><td>Checks for <em>if</em> statements with a constant value for the if expression, such as <em>true</em>, <em>false</em>, <em>null</em>, or a literal constant value.</td></tr><tr class='ruleDescriptions'><td><a name='ConstantTernaryExpression'></a><span class='ruleIndex'>23</span></td><td class='ruleName priority2'>ConstantTernaryExpression</td><td>Checks for ternary expressions with a constant value for the boolean expression, such as <em>true</em>, <em>false</em>, <em>null</em>, or a literal constant value.</td></tr><tr class='ruleDescriptions'><td><a name='CrapMetric'></a><span class='ruleIndex'>24</span></td><td class='ruleName priority2'>CrapMetric</td><td>Checks the CRAP (Change Risk Anti-Patterns) score for methods/classes. The CRAP metric score is based on the cyclomatic complexity and test coverage for individual methods. A method with a CRAP value greater than the <em>maxMethodCrapScore</em> property (30) causes a violation. Likewise, a class that has an (average method) CRAP value greater than the <em>maxClassAverageMethodCrapScore</em> property (30) causes a violation.</td></tr><tr class='ruleDescriptions'><td><a name='CyclomaticComplexity'></a><span class='ruleIndex'>25</span></td><td class='ruleName priority2'>CyclomaticComplexity</td><td>Checks the cyclomatic complexity for methods/classes.A method (or "closure field") with a cyclomatic complexity value greater than the <em>maxMethodComplexity</em> property (20) causes a violation. Likewise, a class that has an (average method) cyclomatic complexityvalue greater than the <em>maxClassAverageMethodComplexity</em> property (20) causes a violation.</td></tr><tr class='ruleDescriptions'><td><a name='DeadCode'></a><span class='ruleIndex'>26</span></td><td class='ruleName priority2'>DeadCode</td><td>Dead code appears after a return statement or an exception is thrown. If code appears after one of these statements then it will never be executed and can be safely deleted.</td></tr><tr class='ruleDescriptions'><td><a name='DoubleNegative'></a><span class='ruleIndex'>27</span></td><td class='ruleName priority2'>DoubleNegative</td><td>There is no point in using a double negative, it is always positive. For instance <em>!!x</em> can always be simplified to x. And <em>!(!x)</em> can as well.</td></tr><tr class='ruleDescriptions'><td><a name='DuplicateCaseStatement'></a><span class='ruleIndex'>28</span></td><td class='ruleName priority2'>DuplicateCaseStatement</td><td>Check for duplicate <em>case</em> statements in a <em>switch</em> block, such as two equal integers or strings.</td></tr><tr class='ruleDescriptions'><td><a name='DuplicateImport'></a><span class='ruleIndex'>29</span></td><td class='ruleName priority3'>DuplicateImport</td><td>Duplicate import statements are unnecessary.</td></tr><tr class='ruleDescriptions'><td><a name='DuplicateMapKey'></a><span class='ruleIndex'>30</span></td><td class='ruleName priority2'>DuplicateMapKey</td><td>A map literal is created with duplicated key. The map entry will be overwritten.</td></tr><tr class='ruleDescriptions'><td><a name='DuplicateSetValue'></a><span class='ruleIndex'>31</span></td><td class='ruleName priority2'>DuplicateSetValue</td><td>A Set literal is created with duplicate constant value. A set cannot contain two elements with the same value.</td></tr><tr class='ruleDescriptions'><td><a name='EmptyCatchBlock'></a><span class='ruleIndex'>32</span></td><td class='ruleName priority2'>EmptyCatchBlock</td><td>In most cases, exceptions should not be caught and ignored (swallowed).</td></tr><tr class='ruleDescriptions'><td><a name='EmptyClass'></a><span class='ruleIndex'>33</span></td><td class='ruleName priority2'>EmptyClass</td><td>Reports classes without methods, fields or properties. Why would you need a class like this?</td></tr><tr class='ruleDescriptions'><td><a name='EmptyElseBlock'></a><span class='ruleIndex'>34</span></td><td class='ruleName priority2'>EmptyElseBlock</td><td>Empty <em>else</em> blocks are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><td><a name='EmptyFinallyBlock'></a><span class='ruleIndex'>35</span></td><td class='ruleName priority2'>EmptyFinallyBlock</td><td>Empty <em>finally</em> blocks are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><td><a name='EmptyForStatement'></a><span class='ruleIndex'>36</span></td><td class='ruleName priority2'>EmptyForStatement</td><td>Empty <em>for</em> statements are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><td><a name='EmptyIfStatement'></a><span class='ruleIndex'>37</span></td><td class='ruleName priority2'>EmptyIfStatement</td><td>Empty <em>if</em> statements are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><td><a name='EmptyInstanceInitializer'></a><span class='ruleIndex'>38</span></td><td class='ruleName priority2'>EmptyInstanceInitializer</td><td>An empty class instance initializer was found. It is safe to remove it.</td></tr><tr class='ruleDescriptions'><td><a name='EmptyMethod'></a><span class='ruleIndex'>39</span></td><td class='ruleName priority2'>EmptyMethod</td><td>A method was found without an implementation. If the method is overriding or implementing a parent method, then mark it with the @Override annotation.</td></tr><tr class='ruleDescriptions'><td><a name='EmptyStaticInitializer'></a><span class='ruleIndex'>40</span></td><td class='ruleName priority2'>EmptyStaticInitializer</td><td>An empty static initializer was found. It is safe to remove it.</td></tr><tr class='ruleDescriptions'><td><a name='EmptySwitchStatement'></a><span class='ruleIndex'>41</span></td><td class='ruleName priority2'>EmptySwitchStatement</td><td>Empty <em>switch</em> statements are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><td><a name='EmptySynchronizedStatement'></a><span class='ruleIndex'>42</span></td><td class='ruleName priority2'>EmptySynchronizedStatement</td><td>Empty <em>synchronized</em> statements are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><td><a name='EmptyTryBlock'></a><span class='ruleIndex'>43</span></td><td class='ruleName priority2'>EmptyTryBlock</td><td>Empty <em>try</em> blocks are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><td><a name='EmptyWhileStatement'></a><span class='ruleIndex'>44</span></td><td class='ruleName priority2'>EmptyWhileStatement</td><td>Empty <em>while</em> statements are confusing and serve no purpose.</td></tr><tr class='ruleDescriptions'><td><a name='EqualsAndHashCode'></a><span class='ruleIndex'>45</span></td><td class='ruleName priority2'>EqualsAndHashCode</td><td>If either the <em>boolean equals(Object)</em> or the <em>int hashCode()</em> methods are overridden within a class, then both must be overridden.</td></tr><tr class='ruleDescriptions'><td><a name='EqualsOverloaded'></a><span class='ruleIndex'>46</span></td><td class='ruleName priority2'>EqualsOverloaded</td><td>The class has an equals method, but the parameter of the method is not of type Object. It is not overriding equals but instead overloading it.</td></tr><tr class='ruleDescriptions'><td><a name='ExplicitArrayListInstantiation'></a><span class='ruleIndex'>47</span></td><td class='ruleName priority2'>ExplicitArrayListInstantiation</td><td>This rule checks for the explicit instantiation of an <em>ArrayList</em> using the no-arg constructor. In Groovy, it is best to write <em>new ArrayList()</em> as <em>[]</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToAndMethod'></a><span class='ruleIndex'>48</span></td><td class='ruleName priority2'>ExplicitCallToAndMethod</td><td>This rule detects when the <em>and(Object)</em> method is called directly in code instead of using the & operator. A groovier way to express this: <em>a.and(b)</em> is this: <em>a & b</em></td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToCompareToMethod'></a><span class='ruleIndex'>49</span></td><td class='ruleName priority2'>ExplicitCallToCompareToMethod</td><td>This rule detects when the <em>compareTo(Object)</em> method is called directly in code instead of using the <=>, >, >=, <, and <= operators. A groovier way to express this: <em>a.compareTo(b)</em> is this: <em>a <=> b</em>, or using the other operators.</td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToDivMethod'></a><span class='ruleIndex'>50</span></td><td class='ruleName priority2'>ExplicitCallToDivMethod</td><td>This rule detects when the <em>div(Object)</em> method is called directly in code instead of using the / operator. A groovier way to express this: <em>a.div(b)</em> is this: <em>a / b</em></td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToEqualsMethod'></a><span class='ruleIndex'>51</span></td><td class='ruleName priority2'>ExplicitCallToEqualsMethod</td><td>This rule detects when the <em>equals(Object)</em> method is called directly in code instead of using the == or != operator. A groovier way to express this: <em>a.equals(b)</em> is this: <em>a == b</em> and a groovier way to express : <em>!a.equals(b)</em> is : <em>a != b</em></td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToGetAtMethod'></a><span class='ruleIndex'>52</span></td><td class='ruleName priority2'>ExplicitCallToGetAtMethod</td><td>This rule detects when the <em>getAt(Object)</em> method is called directly in code instead of using the [] index operator. A groovier way to express this: <em>a.getAt(b)</em> is this: <em>a[b]</em></td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToLeftShiftMethod'></a><span class='ruleIndex'>53</span></td><td class='ruleName priority2'>ExplicitCallToLeftShiftMethod</td><td>This rule detects when the <em>leftShift(Object)</em> method is called directly in code instead of using the << operator. A groovier way to express this: <em>a.leftShift(b)</em> is this: <em>a << b</em></td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToMinusMethod'></a><span class='ruleIndex'>54</span></td><td class='ruleName priority2'>ExplicitCallToMinusMethod</td><td>This rule detects when the <em>minus(Object)</em> method is called directly in code instead of using the - operator. A groovier way to express this: <em>a.minus(b)</em> is this: <em>a - b</em></td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToModMethod'></a><span class='ruleIndex'>55</span></td><td class='ruleName priority2'>ExplicitCallToModMethod</td><td>This rule detects when the <em>mod(Object)</em> method is called directly in code instead of using the % operator. A groovier way to express this: <em>a.mod(b)</em> is this: <em>a % b</em></td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToMultiplyMethod'></a><span class='ruleIndex'>56</span></td><td class='ruleName priority2'>ExplicitCallToMultiplyMethod</td><td>This rule detects when the <em>minus(Object)</em> method is called directly in code instead of using the * operator. A groovier way to express this: <em>a.multiply(b)</em> is this: <em>a * b</em></td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToOrMethod'></a><span class='ruleIndex'>57</span></td><td class='ruleName priority2'>ExplicitCallToOrMethod</td><td>This rule detects when the <em>or(Object)</em> method is called directly in code instead of using the | operator. A groovier way to express this: <em>a.or(b)</em> is this: <em>a | b</em></td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToPlusMethod'></a><span class='ruleIndex'>58</span></td><td class='ruleName priority2'>ExplicitCallToPlusMethod</td><td>This rule detects when the <em>plus(Object)</em> method is called directly in code instead of using the + operator. A groovier way to express this: <em>a.plus(b)</em> is this: <em>a + b</em></td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToPowerMethod'></a><span class='ruleIndex'>59</span></td><td class='ruleName priority2'>ExplicitCallToPowerMethod</td><td>This rule detects when the <em>power(Object)</em> method is called directly in code instead of using the ** operator. A groovier way to express this: <em>a.power(b)</em> is this: <em>a ** b</em></td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToPutAtMethod'></a><span class='ruleIndex'>60</span></td><td class='ruleName priority2'>ExplicitCallToPutAtMethod</td><td>Detects when the putAt(Object, Object) method is called directly in code instead of using the [] index operator. A groovier way to express this: map.putAt(k, v) is this: map[k] = v.</td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToRightShiftMethod'></a><span class='ruleIndex'>61</span></td><td class='ruleName priority2'>ExplicitCallToRightShiftMethod</td><td>This rule detects when the <em>rightShift(Object)</em> method is called directly in code instead of using the >> operator. A groovier way to express this: <em>a.rightShift(b)</em> is this: <em>a >> b</em></td></tr><tr class='ruleDescriptions'><td><a name='ExplicitCallToXorMethod'></a><span class='ruleIndex'>62</span></td><td class='ruleName priority2'>ExplicitCallToXorMethod</td><td>This rule detects when the <em>xor(Object)</em> method is called directly in code instead of using the ^ operator. A groovier way to express this: <em>a.xor(b)</em> is this: <em>a ^ b</em></td></tr><tr class='ruleDescriptions'><td><a name='ExplicitGarbageCollection'></a><span class='ruleIndex'>63</span></td><td class='ruleName priority2'>ExplicitGarbageCollection</td><td>Calls to System.gc(), Runtime.getRuntime().gc(), and System.runFinalization() are not advised. Code should have the same behavior whether the garbage collection is disabled using the option -Xdisableexplicitgc or not. Moreover, "modern" jvms do a very good job handling garbage collections. If memory usage issues unrelated to memory leaks develop within an application, it should be dealt with JVM options rather than within the code itself.</td></tr><tr class='ruleDescriptions'><td><a name='ExplicitHashMapInstantiation'></a><span class='ruleIndex'>64</span></td><td class='ruleName priority2'>ExplicitHashMapInstantiation</td><td>This rule checks for the explicit instantiation of a <em>HashMap</em> using the no-arg constructor. In Groovy, it is best to write <em>new HashMap()</em> as <em>[:]</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><td><a name='ExplicitHashSetInstantiation'></a><span class='ruleIndex'>65</span></td><td class='ruleName priority2'>ExplicitHashSetInstantiation</td><td>This rule checks for the explicit instantiation of a <em>HashSet</em> using the no-arg constructor. In Groovy, it is best to write <em>new HashSet()</em> as <em>[] as Set</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><td><a name='ExplicitLinkedHashMapInstantiation'></a><span class='ruleIndex'>66</span></td><td class='ruleName priority2'>ExplicitLinkedHashMapInstantiation</td><td>This rule checks for the explicit instantiation of a <em>LinkedHashMap</em> using the no-arg constructor. In Groovy, it is best to write <em>new LinkedHashMap()</em> as <em>[:]</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><td><a name='ExplicitLinkedListInstantiation'></a><span class='ruleIndex'>67</span></td><td class='ruleName priority2'>ExplicitLinkedListInstantiation</td><td>This rule checks for the explicit instantiation of a <em>LinkedList</em> using the no-arg constructor. In Groovy, it is best to write <em>new LinkedList()</em> as <em>[] as Queue</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><td><a name='ExplicitStackInstantiation'></a><span class='ruleIndex'>68</span></td><td class='ruleName priority2'>ExplicitStackInstantiation</td><td>This rule checks for the explicit instantiation of a <em>Stack</em> using the no-arg constructor. In Groovy, it is best to write <em>new Stack()</em> as <em>[] as Stack</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><td><a name='ExplicitTreeSetInstantiation'></a><span class='ruleIndex'>69</span></td><td class='ruleName priority2'>ExplicitTreeSetInstantiation</td><td>This rule checks for the explicit instantiation of a <em>TreeSet</em> using the no-arg constructor. In Groovy, it is best to write <em>new TreeSet()</em> as <em>[] as SortedSet</em>, which creates the same object.</td></tr><tr class='ruleDescriptions'><td><a name='ForLoopShouldBeWhileLoop'></a><span class='ruleIndex'>70</span></td><td class='ruleName priority3'>ForLoopShouldBeWhileLoop</td><td>A for loop without an init and update statement can be simplified to a while loop.</td></tr><tr class='ruleDescriptions'><td><a name='GStringAsMapKey'></a><span class='ruleIndex'>71</span></td><td class='ruleName priority2'>GStringAsMapKey</td><td>A GString should not be used as a map key since its hashcode is not guaranteed to be stable. Consider calling <em>key.toString()</em>.</td></tr><tr class='ruleDescriptions'><td><a name='GStringExpressionWithinString'></a><span class='ruleIndex'>72</span></td><td class='ruleName priority2'>GStringExpressionWithinString</td><td>Check for regular (single quote) strings containing a GString-type expression (${...}).</td></tr><tr class='ruleDescriptions'><td><a name='GetterMethodCouldBeProperty'></a><span class='ruleIndex'>73</span></td><td class='ruleName priority3'>GetterMethodCouldBeProperty</td><td>If a class defines a public method that follows the Java getter notation, and returns a constant, then it is cleaner to provide a Groovy property for the value rather than a Groovy method.</td></tr><tr class='ruleDescriptions'><td><a name='GroovyLangImmutable'></a><span class='ruleIndex'>74</span></td><td class='ruleName priority2'>GroovyLangImmutable</td><td>The groovy.lang.Immutable annotation has been deprecated and replaced by groovy.transform.Immutable. Do not use the Immutable in groovy.lang.</td></tr><tr class='ruleDescriptions'><td><a name='HardCodedWindowsFileSeparator'></a><span class='ruleIndex'>75</span></td><td class='ruleName priority2'>HardCodedWindowsFileSeparator</td><td>This rule finds usages of a Windows file separator within the constructor call of a File object. It is better to use the Unix file separator or use the File.separator constant.</td></tr><tr class='ruleDescriptions'><td><a name='HardCodedWindowsRootDirectory'></a><span class='ruleIndex'>76</span></td><td class='ruleName priority2'>HardCodedWindowsRootDirectory</td><td>This rule find cases where a <em>File</em> object is constructed with a windows-based path. This is not portable, and using the <em>File.listRoots()</em> method is a better alternative.</td></tr><tr class='ruleDescriptions'><td><a name='ImportFromSamePackage'></a><span class='ruleIndex'>77</span></td><td class='ruleName priority3'>ImportFromSamePackage</td><td>An import of a class that is within the same package is unnecessary.</td></tr><tr class='ruleDescriptions'><td><a name='ImportFromSunPackages'></a><span class='ruleIndex'>78</span></td><td class='ruleName priority2'>ImportFromSunPackages</td><td>Avoid importing anything from the 'sun.*' packages. These packages are not portable and are likely to change.</td></tr><tr class='ruleDescriptions'><td><a name='IntegerGetInteger'></a><span class='ruleIndex'>79</span></td><td class='ruleName priority2'>IntegerGetInteger</td><td>This rule catches usages of java.lang.Integer.getInteger(String, ...) which reads an Integer from the System properties. It is often mistakenly used to attempt to read user input or parse a String into an Integer. It is a poor piece of API to use; replace it with System.properties['prop'].</td></tr><tr class='ruleDescriptions'><td><a name='MethodCount'></a><span class='ruleIndex'>80</span></td><td class='ruleName priority2'>MethodCount</td><td>A class with too many methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.The <em>maxMethods</em> property (30) specifies the threshold.</td></tr><tr class='ruleDescriptions'><td><a name='MethodSize'></a><span class='ruleIndex'>81</span></td><td class='ruleName priority3'>MethodSize</td><td>Checks if the size of a method exceeds the number of lines specified by the <em>maxLines</em> property (100).</td></tr><tr class='ruleDescriptions'><td><a name='MisorderedStaticImports'></a><span class='ruleIndex'>82</span></td><td class='ruleName priority3'>MisorderedStaticImports</td><td>Static imports should never be declared after nonstatic imports.</td></tr><tr class='ruleDescriptions'><td><a name='MultipleUnaryOperators'></a><span class='ruleIndex'>83</span></td><td class='ruleName priority2'>MultipleUnaryOperators</td><td>Checks for multiple consecutive unary operators. These are confusing, and are likely typos and bugs.</td></tr><tr class='ruleDescriptions'><td><a name='NestedBlockDepth'></a><span class='ruleIndex'>84</span></td><td class='ruleName priority2'>NestedBlockDepth</td><td>Checks for blocks or closures nested more than <em>maxNestedBlockDepth</em> (5) levels deep.</td></tr><tr class='ruleDescriptions'><td><a name='NoWildcardImports'></a><span class='ruleIndex'>85</span></td><td class='ruleName priority3'>NoWildcardImports</td><td>Wildcard imports, static or otherwise, should not be used.</td></tr><tr class='ruleDescriptions'><td><a name='ParameterAssignmentInFilterClosure'></a><span class='ruleIndex'>86</span></td><td class='ruleName priority2'>ParameterAssignmentInFilterClosure</td><td>An assignment operator was used on a parameter in a filtering closure. This is usually a typo, and the comparison operator (==) was intended.</td></tr><tr class='ruleDescriptions'><td><a name='ParameterCount'></a><span class='ruleIndex'>87</span></td><td class='ruleName priority2'>ParameterCount</td><td>Checks if the number of parameters in method/constructor exceeds the number of parameters specified by the maxParameters property.</td></tr><tr class='ruleDescriptions'><td><a name='RandomDoubleCoercedToZero'></a><span class='ruleIndex'>88</span></td><td class='ruleName priority2'>RandomDoubleCoercedToZero</td><td>The Math.random() method returns a double result greater than or equal to 0.0 and less than 1.0. If you coerce this result into an Integer or int, then it is coerced to zero. Casting the result to int, or assigning it to an int field is probably a bug.</td></tr><tr class='ruleDescriptions'><td><a name='RemoveAllOnSelf'></a><span class='ruleIndex'>89</span></td><td class='ruleName priority2'>RemoveAllOnSelf</td><td>Don't use <em>removeAll</em> to clear a collection. If you want to remove all elements from a collection c, use c.clear, not c.removeAll(c). Calling <em>c.removeAll(c)</em> to clear a collection is less clear, susceptible to errors from typos, less efficient and for some collections, might throw a <em>ConcurrentModificationException</em>.</td></tr><tr class='ruleDescriptions'><td><a name='ReturnFromFinallyBlock'></a><span class='ruleIndex'>90</span></td><td class='ruleName priority2'>ReturnFromFinallyBlock</td><td>Returning from a <em>finally</em> block is confusing and can hide the original exception.</td></tr><tr class='ruleDescriptions'><td><a name='ThrowExceptionFromFinallyBlock'></a><span class='ruleIndex'>91</span></td><td class='ruleName priority2'>ThrowExceptionFromFinallyBlock</td><td>Throwing an exception from a <em>finally</em> block is confusing and can hide the original exception.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryBigDecimalInstantiation'></a><span class='ruleIndex'>92</span></td><td class='ruleName priority3'>UnnecessaryBigDecimalInstantiation</td><td>It is unnecessary to instantiate BigDecimal objects. Instead just use the decimal literal or the 'G' identifier to force the type, such as 123.45 or 123.45G.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryBigIntegerInstantiation'></a><span class='ruleIndex'>93</span></td><td class='ruleName priority3'>UnnecessaryBigIntegerInstantiation</td><td>It is unnecessary to instantiate BigInteger objects. Instead just use the literal with the 'G' identifier to force the type, such as 8G or 42G.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryBooleanExpression'></a><span class='ruleIndex'>94</span></td><td class='ruleName priority3'>UnnecessaryBooleanExpression</td><td>Checks for unnecessary boolean expressions, including ANDing (&&) or ORing (||) with <em>true</em>, <em>false</em>, <em>null</em>, or a Map/List/String/Number literal. Also checks for negation (!) of <em>true</em>, <em>false</em>, <em>null</em>, or a Map/List/String/Number literal.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryBooleanInstantiation'></a><span class='ruleIndex'>95</span></td><td class='ruleName priority3'>UnnecessaryBooleanInstantiation</td><td>Use <em>Boolean.valueOf()</em> for variable values or <em>Boolean.TRUE</em> and <em>Boolean.FALSE</em> for constant values instead of calling the <em>Boolean()</em> constructor directly or calling <em>Boolean.valueOf(true)</em> or <em>Boolean.valueOf(false)</em>.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryCallForLastElement'></a><span class='ruleIndex'>96</span></td><td class='ruleName priority3'>UnnecessaryCallForLastElement</td><td>This rule checks for excessively verbose methods of accessing the last element of an array or list. For instance, it is possible to access the last element of an array by performing array[array.length - 1], in Groovy it is simpler to either call array.last() or array[-1]. The same is true for lists. This violation is triggered whenever a get, getAt, or array-style access is used with an object size check.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryCallToSubstring'></a><span class='ruleIndex'>97</span></td><td class='ruleName priority3'>UnnecessaryCallToSubstring</td><td>Calling String.substring(0) always returns the original string. This code is meaningless.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryCast'></a><span class='ruleIndex'>98</span></td><td class='ruleName priority2'>UnnecessaryCast</td><td>Checks for unnecessary cast operations</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryCatchBlock'></a><span class='ruleIndex'>99</span></td><td class='ruleName priority3'>UnnecessaryCatchBlock</td><td>Violations are triggered when a catch block does nothing but throw the original exception. In this scenario there is usually no need for a catch block, just let the exception be thrown from the original code. This condition frequently occurs when catching an exception for debugging purposes but then forgetting to take the catch statement out.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryCollectCall'></a><span class='ruleIndex'>100</span></td><td class='ruleName priority3'>UnnecessaryCollectCall</td><td>Some method calls to Object.collect(Closure) can be replaced with the spread operator. For instance, list.collect { it.multiply(2) } can be replaced by list*.multiply(2). Warning: if a collection is null, collect will return an empty list, while *. will return null.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryCollectionCall'></a><span class='ruleIndex'>101</span></td><td class='ruleName priority3'>UnnecessaryCollectionCall</td><td>Useless call to collections. This call doesn't make sense. For any collection c, calling <em>c.containsAll(c)</em> should always be true, and <em>c.retainAll(c)</em> should have no effect.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryConstructor'></a><span class='ruleIndex'>102</span></td><td class='ruleName priority3'>UnnecessaryConstructor</td><td>This rule detects when a constructor is not necessary; i.e., when there's only one constructor, it's public, has an empty body, and takes no arguments.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryDefInFieldDeclaration'></a><span class='ruleIndex'>103</span></td><td class='ruleName priority3'>UnnecessaryDefInFieldDeclaration</td><td>If a field has a visibility modifier or a type declaration, then the def keyword is unneeded. For instance, 'static def constraints = {}' is redundant and can be simplified to 'static constraints = {}.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryDefInMethodDeclaration'></a><span class='ruleIndex'>104</span></td><td class='ruleName priority3'>UnnecessaryDefInMethodDeclaration</td><td>If a method has a visibility modifier or a type declaration, then the def keyword is unneeded. For instance 'def private method() {}' is redundant and can be simplified to 'private method() {}'.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryDefInVariableDeclaration'></a><span class='ruleIndex'>105</span></td><td class='ruleName priority3'>UnnecessaryDefInVariableDeclaration</td><td>If a variable has a visibility modifier or a type declaration, then the def keyword is unneeded. For instance 'def private n = 2' is redundant and can be simplified to 'private n = 2'.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryDotClass'></a><span class='ruleIndex'>106</span></td><td class='ruleName priority3'>UnnecessaryDotClass</td><td>To make a reference to a class, it is unnecessary to specify the '.class' identifier. For instance String.class can be shortened to String.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryDoubleInstantiation'></a><span class='ruleIndex'>107</span></td><td class='ruleName priority3'>UnnecessaryDoubleInstantiation</td><td>It is unnecessary to instantiate Double objects. Instead just use the double literal or the 'D' identifier to force the type, such as 123.45d or 0.42d.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryElseStatement'></a><span class='ruleIndex'>108</span></td><td class='ruleName priority3'>UnnecessaryElseStatement</td><td>When an if statement block ends with a return statement the else is unnecessary. The logic in the else branch can be run without being in a new scope.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryFinalOnPrivateMethod'></a><span class='ruleIndex'>109</span></td><td class='ruleName priority3'>UnnecessaryFinalOnPrivateMethod</td><td>A private method is marked final. Private methods cannot be overridden, so marking it final is unnecessary.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryFloatInstantiation'></a><span class='ruleIndex'>110</span></td><td class='ruleName priority3'>UnnecessaryFloatInstantiation</td><td>It is unnecessary to instantiate Float objects. Instead just use the float literal with the 'F' identifier to force the type, such as 123.45F or 0.42f.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryGString'></a><span class='ruleIndex'>111</span></td><td class='ruleName priority3'>UnnecessaryGString</td><td>String objects should be created with single quotes, and GString objects created with double quotes. Creating normal String objects with double quotes is confusing to readers.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryGroovyImport'></a><span class='ruleIndex'>112</span></td><td class='ruleName priority3'>UnnecessaryGroovyImport</td><td>A Groovy file does not need to include an import for classes from <em>java.lang</em>, <em>java.util</em>, <em>java.io</em>, <em>java.net</em>, <em>groovy.lang</em> and <em>groovy.util</em>, as well as the classes <em>java.math.BigDecimal</em> and <em>java.math.BigInteger</em>.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryIfStatement'></a><span class='ruleIndex'>113</span></td><td class='ruleName priority3'>UnnecessaryIfStatement</td><td>Checks for <em>if</em> statements where the if and else blocks (or subsequent fall-through to a <em>return</em>) are merely returning <em>true</em> and <em>false</em> constants. These cases can be replaced by a simple return statement.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryInstanceOfCheck'></a><span class='ruleIndex'>114</span></td><td class='ruleName priority3'>UnnecessaryInstanceOfCheck</td><td>This rule finds instanceof checks that cannot possibly evaluate to true. For instance, checking that (!variable instanceof String) will never be true because the result of a not expression is always a boolean.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryInstantiationToGetClass'></a><span class='ruleIndex'>115</span></td><td class='ruleName priority3'>UnnecessaryInstantiationToGetClass</td><td>Avoid instantiating an object just to call getClass() on it; use the .class public member instead.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryIntegerInstantiation'></a><span class='ruleIndex'>116</span></td><td class='ruleName priority3'>UnnecessaryIntegerInstantiation</td><td>It is unnecessary to instantiate Integer objects. Instead just use the literal with the 'I' identifier to force the type, such as 8I or 42i.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryLongInstantiation'></a><span class='ruleIndex'>117</span></td><td class='ruleName priority3'>UnnecessaryLongInstantiation</td><td>It is unnecessary to instantiate Long objects. Instead just use the literal with the 'L' identifier to force the type, such as 8L or 42L.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryModOne'></a><span class='ruleIndex'>118</span></td><td class='ruleName priority3'>UnnecessaryModOne</td><td>Any expression mod 1 (exp % 1) is guaranteed to always return zero. This code is probably an error, and should be either (exp & 1) or (exp % 2).</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryNullCheck'></a><span class='ruleIndex'>119</span></td><td class='ruleName priority3'>UnnecessaryNullCheck</td><td>Groovy contains the safe dereference operator, which can be used in boolean conditional statements to safely replace explicit "x == null" tests.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryNullCheckBeforeInstanceOf'></a><span class='ruleIndex'>120</span></td><td class='ruleName priority3'>UnnecessaryNullCheckBeforeInstanceOf</td><td>There is no need to check for null before an instanceof; the instanceof keyword returns false when given a null argument.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryObjectReferences'></a><span class='ruleIndex'>121</span></td><td class='ruleName priority3'>UnnecessaryObjectReferences</td><td>Violations are triggered when an excessive set of consecutive statements all reference the same variable. This can be made more readable by using a with or identity block.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryOverridingMethod'></a><span class='ruleIndex'>122</span></td><td class='ruleName priority3'>UnnecessaryOverridingMethod</td><td>The overriding method merely calls the same method defined in a superclass</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryPackageReference'></a><span class='ruleIndex'>123</span></td><td class='ruleName priority3'>UnnecessaryPackageReference</td><td>Checks for explicit package reference for classes that Groovy imports by default, such as <em>java.lang.String</em>, <em>java.util.Map</em> and <em>groovy.lang.Closure</em>.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryParenthesesForMethodCallWithClosure'></a><span class='ruleIndex'>124</span></td><td class='ruleName priority3'>UnnecessaryParenthesesForMethodCallWithClosure</td><td>If a method is called and the only parameter to that method is an inline closure then the parentheses of the method call can be omitted.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryPublicModifier'></a><span class='ruleIndex'>125</span></td><td class='ruleName priority3'>UnnecessaryPublicModifier</td><td>The 'public' modifier is not required on methods or classes.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryReturnKeyword'></a><span class='ruleIndex'>126</span></td><td class='ruleName priority3'>UnnecessaryReturnKeyword</td><td>In Groovy, the return <em>keyword</em> is often optional. If a statement is the last line in a method or closure then you do not need to have the <em>return</em> keyword.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessarySafeNavigationOperator'></a><span class='ruleIndex'>127</span></td><td class='ruleName priority3'>UnnecessarySafeNavigationOperator</td><td>Check for the <em>safe navigation operator</em> (?.) applied to constants and literals, which can never be null.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessarySelfAssignment'></a><span class='ruleIndex'>128</span></td><td class='ruleName priority3'>UnnecessarySelfAssignment</td><td>Method contains a pointless self-assignment to a variable or property.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessarySemicolon'></a><span class='ruleIndex'>129</span></td><td class='ruleName priority3'>UnnecessarySemicolon</td><td>Semicolons as line terminators are not required in Groovy: remove them. Do not use a semicolon as a replacement for empty braces on for and while loops; this is a confusing practice.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessarySetter'></a><span class='ruleIndex'>130</span></td><td class='ruleName priority3'>UnnecessarySetter</td><td>Checks for explicit calls to setter methods which can, for the most part, be replaced by assignment to property. A setter is defined as a method call that matches set[A-Z] but not set[A-Z][A-Z] such as setURL(). Setters take one method argument.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryStringInstantiation'></a><span class='ruleIndex'>131</span></td><td class='ruleName priority3'>UnnecessaryStringInstantiation</td><td>Use a String literal (e.g., "...") instead of calling the corresponding String constructor (new String("..")) directly.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessarySubstring'></a><span class='ruleIndex'>132</span></td><td class='ruleName priority3'>UnnecessarySubstring</td><td>This rule finds usages of String.substring(int) and String.substring(int, int) that can be replaced by use of the subscript operator. For instance, var.substring(5) can be replaced with var[5..-1].</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryTernaryExpression'></a><span class='ruleIndex'>133</span></td><td class='ruleName priority3'>UnnecessaryTernaryExpression</td><td>Checks for ternary expressions where the conditional expression always evaluates to a boolean and the true and false expressions are merely returning <em>true</em> and <em>false</em> constants. Also checks for ternary expressions where both expressions are the same constant or variable.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryToString'></a><span class='ruleIndex'>134</span></td><td class='ruleName priority2'>UnnecessaryToString</td><td>Checks for unnecessary calls to <em>toString()</em>.</td></tr><tr class='ruleDescriptions'><td><a name='UnnecessaryTransientModifier'></a><span class='ruleIndex'>135</span></td><td class='ruleName priority3'>UnnecessaryTransientModifier</td><td>The field is marked as transient, but the class isn't Serializable, so marking it as transient has no effect.</td></tr><tr class='ruleDescriptions'><td><a name='UnusedImport'></a><span class='ruleIndex'>136</span></td><td class='ruleName priority3'>UnusedImport</td><td>Imports for a class that is never referenced within the source file is unnecessary.</td></tr><tr class='ruleDescriptions'><td><a name='UseCollectMany'></a><span class='ruleIndex'>137</span></td><td class='ruleName priority2'>UseCollectMany</td><td>In many case <em>collectMany()</em> yields the same result as <em>collect{}.flatten()</em>. It is easier to understand and more clearly conveys the intent.</td></tr><tr class='ruleDescriptions'><td><a name='UseCollectNested'></a><span class='ruleIndex'>138</span></td><td class='ruleName priority2'>UseCollectNested</td><td>Instead of nested collect{}-calls use collectNested{}</td></tr></table></div></body></html>