/
SampleCodeNarcTextReport.txt
518 lines (471 loc) · 29.7 KB
/
SampleCodeNarcTextReport.txt
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
CodeNarc Report: Sample Project - Sep 9, 2017 12:34:41 PM
Summary: TotalFiles=365 FilesWithViolations=37 P1=0 P2=52 P3=29
File: AbstractAstVisitorRuleTest.groovy
Violation: Rule=MisorderedStaticImports P=3 Line=22 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.test.TestUtil.shouldFailWithMessageContaining]
Violation: Rule=MisorderedStaticImports P=3 Line=23 Msg=[Static imports should appear before normal imports] Src=[import static org.junit.Assert.assertFalse]
Violation: Rule=UnnecessaryObjectReferences P=3 Line=184 Msg=[The code could be more concise by using a with() or identity() block] Src=[rule.doNotApplyToClassNames = 'Xxx' // doNotApply = NO]
Violation: Rule=UnnecessaryObjectReferences P=3 Line=187 Msg=[The code could be more concise by using a with() or identity() block] Src=[rule.applyToClassNames = 'Xxx' // apply = NO]
Violation: Rule=UnnecessaryObjectReferences P=3 Line=188 Msg=[The code could be more concise by using a with() or identity() block] Src=[rule.doNotApplyToClassNames = 'Xxx' // doNotApply = NO]
File: AbstractRuleTest.groovy
Violation: Rule=MisorderedStaticImports P=3 Line=24 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.test.TestUtil.assertContainsAll]
Violation: Rule=MisorderedStaticImports P=3 Line=25 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.test.TestUtil.shouldFailWithMessageContaining]
Violation: Rule=UnnecessaryObjectReferences P=3 Line=137 Msg=[The code could be more concise by using a with() or identity() block] Src=[rule.doNotApplyToFilesMatching = NO_MATCH // doNotApply = NO]
Violation: Rule=UnnecessaryObjectReferences P=3 Line=140 Msg=[The code could be more concise by using a with() or identity() block] Src=[rule.applyToFilesMatching = NO_MATCH // apply = NO]
Violation: Rule=UnnecessaryObjectReferences P=3 Line=141 Msg=[The code could be more concise by using a with() or identity() block] Src=[rule.doNotApplyToFilesMatching = NO_MATCH // doNotApply = NO]
Violation: Rule=UnnecessaryObjectReferences P=3 Line=177 Msg=[The code could be more concise by using a with() or identity() block] Src=[rule.applyToFileNames = 'org/codenarc/MyOtherTest.groovy']
Violation: Rule=UnnecessaryObjectReferences P=3 Line=225 Msg=[The code could be more concise by using a with() or identity() block] Src=[rule.doNotApplyToFileNames = 'Xxx.groovy' // doNotApply = NO]
Violation: Rule=UnnecessaryObjectReferences P=3 Line=228 Msg=[The code could be more concise by using a with() or identity() block] Src=[rule.applyToFileNames = 'Xxx.groovy' // apply = NO]
Violation: Rule=UnnecessaryObjectReferences P=3 Line=229 Msg=[The code could be more concise by using a with() or identity() block] Src=[rule.doNotApplyToFileNames = 'Xxx.groovy' // doNotApply = NO]
File: InlineViolationsParserTest.groovy
Violation: Rule=MisorderedStaticImports P=3 Line=20 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.rule.InlineViolationsParser.inlineViolation]
Violation: Rule=UnnecessaryReturnKeyword P=3 Line=199 Msg=[The return keyword is not needed and can be removed] Src=[return [lineNumber: lineNumber, sourceLineText: sourceLineText, messageText: messageText]]
File: design/NestedForLoopRuleTest.groovy
Violation: Rule=UnnecessaryReturnKeyword P=3 Line=105 Msg=[The return keyword is not needed and can be removed] Src=[return inlineViolation('Nested for loop')]
File: design/PrivateFieldCouldBeFinalRuleTest.groovy
Violation: Rule=MethodCount P=2 Line=27 Msg=[Class org.codenarc.rule.design.PrivateFieldCouldBeFinalRuleTest has 33 methods] Src=[class PrivateFieldCouldBeFinalRuleTest extends AbstractRuleTestCase {]
File: formatting/BracesForForLoopRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=102 Msg=[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 {}'] Src=[final SOURCE = ''']
File: formatting/BracesForIfElseRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=60 Msg=[The String '
if (someContainer."${SomeClass.SOME_CONSTANT}" != null) // And what about {}
{
doStuff()
}
' contains a GString-type expression: '${SomeClass.SOME_CONSTANT}" != null) // And what about {}'] Src=[final SOURCE = ''']
File: formatting/BracesForMethodRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=286 Msg=[The String '
class MyClass {
int size(String name = "${SomeClass.SOME_CONSTANT}")
{
return 99
}
}
' contains a GString-type expression: '${SomeClass.SOME_CONSTANT}'] Src=[final SOURCE = ''']
File: formatting/SpaceAfterClosingBraceRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=39 Msg=[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") { }'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=293 Msg=[The String '
def foo = 1
"I am a ${ -> foo }"
' contains a GString-type expression: '${ -> foo }'] Src=[assertNoViolations(''']
Violation: Rule=GStringExpressionWithinString P=2 Line=301 Msg=[The String '
def foo = 1
"I am a ${ -> foo }0"
' contains a GString-type expression: '${ -> foo }'] Src=[assertNoViolations(''']
File: formatting/SpaceAfterOpeningBraceRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=39 Msg=[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") { }'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=79 Msg=[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") {}'] Src=[final SOURCE = ''']
File: formatting/SpaceAroundMapEntryColonRuleTest.groovy
Violation: Rule=UnnecessaryReturnKeyword P=3 Line=116 Msg=[The return keyword is not needed and can be removed] Src=[return inlineViolation("The colon for the literal Map entry for key [$keyName] within class $className" +]
File: formatting/SpaceBeforeClosingBraceRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=40 Msg=[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") { }'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=81 Msg=[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") {}'] Src=[final SOURCE = ''']
File: formatting/SpaceBeforeOpeningBraceRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=39 Msg=[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") { }'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=255 Msg=[The String '
def foo = 1
"I am a ${ -> foo }"
' contains a GString-type expression: '${ -> foo }'] Src=[assertNoViolations(''']
File: generic/IllegalPackageReferenceRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=65 Msg=[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}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=73 Msg=[The String 'println "isClosure=${value instanceof org.bad.OtherClass}"' contains a GString-type expression: '${value instanceof org.bad.OtherClass}'] Src=[[lineNumber:3, sourceLineText:'println "isClosure=${value instanceof org.bad.OtherClass}"', messageText:'org.bad'],]
File: generic/RequiredRegexRuleTest.groovy
Violation: Rule=MisorderedStaticImports P=3 Line=22 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.test.TestUtil.containsAll]
File: grails/GrailsMassAssignmentRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=37 Msg=[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() }'] Src=[final SOURCE = ''']
File: grails/GrailsServletContextReferenceRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=79 Msg=[The String '
class MyClass {
def mySession = servletContext
def edit = {
println "amount=${servletContext.amount}"
}
}
' contains a GString-type expression: '${servletContext.amount}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=88 Msg=[The String 'println "amount=${servletContext.amount}"' contains a GString-type expression: '${servletContext.amount}'] Src=[assertTwoViolations(SOURCE, 3, 'def mySession = servletContext', 6, 'println "amount=${servletContext.amount}"')]
File: groovyism/GStringAsMapKeyRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=45 Msg=[The String '
Map map = ["${ someRef }" : 'invalid' ]
' contains a GString-type expression: '${ someRef }'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=49 Msg=[The String '["${ someRef }" :' contains a GString-type expression: '${ someRef }'] Src=[2, '["${ someRef }" :')]
File: groovyism/GStringExpressionWithinStringRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=50 Msg=[The String '
class SomeClass {
@SomeAnnotationOnField('${sample.property1}')
String sampleProperty
@SomeAnnotationOnMethod('${sample.property2}')
void method() {
}
}
' contains a GString-type expression: '${sample.property1}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=65 Msg=[The String '
@SomeAnnotationOnClass('${sample.property1}')
class SomeClass {
@SomeAnnotationOnField('${sample.property2}')
String sampleProperty
@SomeAnnotationOnMethod('${sample.property3}')
void method() {
}
}
' contains a GString-type expression: '${sample.property1}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=81 Msg=[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}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=94 Msg=[The String '
@SomeAnnotationOnClass(attribute=['${sample.property1}', '${sample.property2}'])
class SomeClass {
}
' contains a GString-type expression: '${sample.property1}', '${sample.property2}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=104 Msg=[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}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=120 Msg=[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)}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=143 Msg=[The String '
def str1 = 'total: ${count}'
def str2 = 'average: ${total / count}'
' contains a GString-type expression: '${count}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=148 Msg=[The String 'def str1 = 'total: ${count}'' contains a GString-type expression: '${count}'] Src=[[lineNumber:2, sourceLineText:"def str1 = 'total: \${count}'", messageText:'\'${count}\''],]
Violation: Rule=GStringExpressionWithinString P=2 Line=148 Msg=[The String ''${count}'' contains a GString-type expression: '${count}'] Src=[[lineNumber:2, sourceLineText:"def str1 = 'total: \${count}'", messageText:'\'${count}\''],]
Violation: Rule=GStringExpressionWithinString P=2 Line=149 Msg=[The String 'def str2 = 'average: ${total / count}'' contains a GString-type expression: '${total / count}'] Src=[[lineNumber:3, sourceLineText:"def str2 = 'average: \${total / count}'", messageText:'\'${total / count}\''])]
Violation: Rule=GStringExpressionWithinString P=2 Line=149 Msg=[The String ''${total / count}'' contains a GString-type expression: '${total / count}'] Src=[[lineNumber:3, sourceLineText:"def str2 = 'average: \${total / count}'", messageText:'\'${total / count}\''])]
Violation: Rule=GStringExpressionWithinString P=2 Line=154 Msg=[The String '
class SomeClass {
@SomeAnnotationOnMethod('${sample.property}')
void method() {
def str1 = 'total: ${count}'
}
}
' contains a GString-type expression: '${sample.property}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=162 Msg=[The String 'def str1 = 'total: ${count}'' contains a GString-type expression: '${count}'] Src=[assertSingleViolation(SOURCE, 5, "def str1 = 'total: \${count}'", '\'${count}\'')]
Violation: Rule=GStringExpressionWithinString P=2 Line=162 Msg=[The String ''${count}'' contains a GString-type expression: '${count}'] Src=[assertSingleViolation(SOURCE, 5, "def str1 = 'total: \${count}'", '\'${count}\'')]
File: imports/UnusedImportRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=193 Msg=[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}'] Src=[final SOURCE = ''']
File: naming/ClassNameRuleTest.groovy
Violation: Rule=MisorderedStaticImports P=3 Line=22 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.test.TestUtil.shouldFailWithMessageContaining]
File: naming/FieldNameRuleTest.groovy
Violation: Rule=MethodCount P=2 Line=29 Msg=[Class org.codenarc.rule.naming.FieldNameRuleTest has 32 methods] Src=[class FieldNameRuleTest extends AbstractRuleTestCase {]
Violation: Rule=MisorderedStaticImports P=3 Line=22 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.test.TestUtil.shouldFailWithMessageContaining]
File: naming/MethodNameRuleTest.groovy
Violation: Rule=MisorderedStaticImports P=3 Line=22 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.test.TestUtil.shouldFailWithMessageContaining]
File: naming/PackageNameRuleTest.groovy
Violation: Rule=MisorderedStaticImports P=3 Line=22 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.test.TestUtil.shouldFailWithMessageContaining]
File: naming/ParameterNameRuleTest.groovy
Violation: Rule=MisorderedStaticImports P=3 Line=22 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.test.TestUtil.shouldFailWithMessageContaining]
File: naming/PropertyNameRuleTest.groovy
Violation: Rule=MisorderedStaticImports P=3 Line=22 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.test.TestUtil.shouldFailWithMessageContaining]
File: naming/VariableNameRuleTest.groovy
Violation: Rule=MisorderedStaticImports P=3 Line=22 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.test.TestUtil.shouldFailWithMessageContaining]
File: size/GMetricsSourceCodeAdapterTest.groovy
Violation: Rule=MisorderedStaticImports P=3 Line=22 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.test.TestUtil.shouldFailWithMessageContaining]
File: size/ParameterCountRuleTest.groovy
Violation: Rule=MisorderedStaticImports P=3 Line=22 Msg=[Static imports should appear before normal imports] Src=[import static org.codenarc.test.TestUtil.shouldFail]
Violation: Rule=UnnecessaryReturnKeyword P=3 Line=253 Msg=[The return keyword is not needed and can be removed] Src=[return inlineViolation("Number of parameters in ${name} exceeds maximum allowed (${rule.maxParameters}).")]
File: unnecessary/ConsecutiveStringConcatenationRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=66 Msg=[The String '
def b = "$Hello" + 'World' // should be "${Hello}World"
' contains a GString-type expression: '${Hello}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=74 Msg=[The String '
def c = 'Hello' + "$World" // should be "Hello${World}"
' contains a GString-type expression: '${World}'] Src=[final SOURCE = ''']
File: unnecessary/UnnecessaryGStringRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=37 Msg=[The String '
def docFile = "src/site/apt/codenarc-rules-${ruleSetName}.apt"
' contains a GString-type expression: '${ruleSetName}'] Src=[final SOURCE = ''']
File: unnecessary/UnnecessaryPackageReferenceRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=68 Msg=[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}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=75 Msg=[The String 'println "isClosure=${value instanceof groovy.lang.Closure}"' contains a GString-type expression: '${value instanceof groovy.lang.Closure}'] Src=[[lineNumber:3, sourceLineText:'println "isClosure=${value instanceof groovy.lang.Closure}"', messageText:'groovy.lang'],]
File: unused/UnusedMethodParameterRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=136 Msg=[The String '
class MyClass {
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}" }'] Src=[final SOURCE = ''']
File: unused/UnusedPrivateFieldRuleTest.groovy
Violation: Rule=MethodCount P=2 Line=29 Msg=[Class org.codenarc.rule.unused.UnusedPrivateFieldRuleTest has 32 methods] Src=[class UnusedPrivateFieldRuleTest extends AbstractRuleTestCase {]
Violation: Rule=GStringExpressionWithinString P=2 Line=168 Msg=[The String '
class MyClass {
private int count
def other = this."${'count'}"
}
' contains a GString-type expression: '${'count'}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=179 Msg=[The String '
class MyClass {
private int count
def varName = "count"
def other = this."${varName}" // can't see this
}
' contains a GString-type expression: '${varName}'] Src=[final SOURCE = ''']
File: unused/UnusedPrivateMethodParameterRuleTest.groovy
Violation: Rule=GStringExpressionWithinString P=2 Line=112 Msg=[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}" }'] Src=[final SOURCE = ''']
File: unused/UnusedPrivateMethodRuleTest.groovy
Violation: Rule=MethodCount P=2 Line=27 Msg=[Class org.codenarc.rule.unused.UnusedPrivateMethodRuleTest has 36 methods] Src=[class UnusedPrivateMethodRuleTest extends AbstractRuleTestCase {]
Violation: Rule=GStringExpressionWithinString P=2 Line=355 Msg=[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()}" }'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=424 Msg=[The String '
class MyClass {
static int getTotal() {
println "total=${MyClass.countStuff()}"
}
private static int countStuff() { }
}
' contains a GString-type expression: '${MyClass.countStuff()}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=437 Msg=[The String '
class MyClass {
private int countStuff() { }
def other = this."${countStuff}"()
}
' contains a GString-type expression: '${countStuff}'] Src=[final SOURCE = ''']
Violation: Rule=GStringExpressionWithinString P=2 Line=459 Msg=[The String '
class MyClass {
private int countStuff() { }
def varName = "countStuff"
def other = this."${varName}"() // can't see this
}
' contains a GString-type expression: '${varName}'] Src=[final SOURCE = ''']
File: unused/UnusedVariableRuleTest.groovy
Violation: Rule=MethodCount P=2 Line=27 Msg=[Class org.codenarc.rule.unused.UnusedVariableRuleTest has 35 methods] Src=[class UnusedVariableRuleTest extends AbstractRuleTestCase {]
[CodeNarc (http://www.codenarc.org) v1.0]