Skip to content

Commit e08ab2d

Browse files
committed
Update CodeNarc version to 2.2.0
1 parent a0857bc commit e08ab2d

5 files changed

Lines changed: 30 additions & 26 deletions

File tree

buildSrc/src/main/kotlin/net/kautler/codenarc.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019 Bjoern Kautler
2+
* Copyright 2019-2023 Bjoern Kautler
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,8 +25,8 @@ val versions: Map<String, String> by project
2525

2626
codenarc {
2727
toolVersion = versions.safeGet("codenarc")
28-
// customized copy from http://codenarc.sourceforge.net/StarterRuleSet-AllRulesByCategory.groovy.txt
29-
// update with new rules when version is updated (previous version: 1.4)
28+
// customized copy from https://github.com/CodeNarc/CodeNarc/blob/v2.2.0/docs/StarterRuleSet-AllRulesByCategory.groovy.txt
29+
// update with new rules when version is updated (previous version: 2.2.0)
3030
config = resources.text.fromFile("config/codenarc/codenarc.groovy")
3131
}
3232

buildSrc/src/main/kotlin/net/kautler/versions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ val versions by extra(mapOf(
4949
"antlr" to "4.7.2",
5050

5151
// tool versions
52-
"codenarc" to "1.4",
52+
"codenarc" to "2.2.0",
5353
"findsecbugs" to "1.9.0",
5454
"jacoco" to "0.8.5",
5555
"pitest" to "1.17.4",

config/codenarc/codenarc.groovy

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Björn Kautler
2+
* Copyright 2019-2023 Björn Kautler
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -73,6 +73,7 @@ ruleset {
7373
HardCodedWindowsRootDirectory
7474
IntegerGetInteger
7575
MultipleUnaryOperators
76+
ParameterAssignmentInFilterClosure
7677
RandomDoubleCoercedToZero
7778
RemoveAllOnSelf
7879
ReturnFromFinallyBlock
@@ -137,12 +138,20 @@ ruleset {
137138
//FieldTypeRequired
138139
HashtableIsObsolete
139140
IfStatementCouldBeTernary
141+
//ImplicitClosureParameter
142+
//ImplicitReturnStatement
140143
InvertedCondition
141144
InvertedIfElse
142145
LongLiteralWithLowerCaseL
143146
//MethodParameterTypeRequired
144147
//MethodReturnTypeRequired
145148
//NoDef
149+
NoDouble {
150+
doNotApplyToClassNames = 'net.kautler.test.PrivateFinalFieldSetterCategory'
151+
}
152+
NoFloat {
153+
doNotApplyToClassNames = 'net.kautler.test.PrivateFinalFieldSetterCategory'
154+
}
146155
NoJavaUtilDate
147156
NoTabCharacter
148157
//ParameterReassignment
@@ -177,6 +186,9 @@ ruleset {
177186
}
178187
LocaleSetDefault
179188
NestedForLoop
189+
OptionalCollectionReturnType
190+
OptionalField
191+
OptionalMethodParameter
180192
PrivateFieldCouldBeFinal
181193
PublicInstanceField
182194
ReturnsNullInsteadOfEmptyArray
@@ -237,17 +249,15 @@ ruleset {
237249
//LineLength
238250
MissingBlankLineAfterImports
239251
MissingBlankLineAfterPackage
252+
MissingBlankLineBeforeAnnotatedField
240253
SpaceAfterCatch
241-
SpaceAfterClosingBrace {
242-
// work-around for https://github.com/CodeNarc/CodeNarc/issues/452
243-
doNotApplyToClassNames = [
244-
'net.kautler.command.integ.test.javacord.spock.JavacordExtension',
245-
'net.kautler.command.integ.test.jda.spock.JdaExtension'
246-
].join(', ')
247-
}
254+
SpaceAfterClosingBrace
248255
SpaceAfterComma
249256
SpaceAfterFor
250257
SpaceAfterIf
258+
SpaceAfterMethodCallName
259+
SpaceAfterMethodDeclarationName
260+
SpaceAfterNotOperator
251261
SpaceAfterOpeningBrace
252262
SpaceAfterSemicolon
253263
SpaceAfterSwitch
@@ -258,12 +268,8 @@ ruleset {
258268
}
259269
SpaceAroundOperator
260270
SpaceBeforeClosingBrace
261-
SpaceBeforeOpeningBrace {
262-
doNotApplyToClassNames = [
263-
'net.kautler.command.util.lazy.LazyReferenceByFunctionTest$1',
264-
'net.kautler.command.util.lazy.LazyReferenceBySupplierTest$1'
265-
].join(', ')
266-
}
271+
SpaceBeforeOpeningBrace
272+
SpaceInsideParentheses
267273
TrailingWhitespace
268274

269275
// rulesets/generic.xml
@@ -278,6 +284,7 @@ ruleset {
278284
StatelessClass
279285

280286
// rulesets/grails.xml
287+
GrailsDomainGormMethods
281288
GrailsDomainHasEquals
282289
GrailsDomainHasToString
283290
GrailsDomainReservedSqlKeywordName
@@ -337,12 +344,7 @@ ruleset {
337344
ExplicitTreeSetInstantiation
338345
GStringAsMapKey
339346
GStringExpressionWithinString
340-
GetterMethodCouldBeProperty {
341-
doNotApplyToClassNames = [
342-
'net.kautler.command.integ.test.javacord.restriction.RestrictionChainElementIntegTest$PingCommand',
343-
'net.kautler.command.integ.test.jda.restriction.RestrictionChainElementIntegTest$PingCommand'
344-
].join(', ')
345-
}
347+
GetterMethodCouldBeProperty
346348
GroovyLangImmutable
347349
UseCollectMany
348350
UseCollectNested

src/javacordIntegTest/groovy/net/kautler/command/integ/test/VersionIntegTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2022 Björn Kautler
2+
* Copyright 2020-2023 Björn Kautler
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ class VersionIntegTest extends Specification {
4343
@AddBean(VersionHolder)
4444
def 'display version should be equal to version if and only if the version is not a snapshot version'() {
4545
expect:
46-
with (VersionHolder.version) {
46+
with(VersionHolder.version) {
4747
(displayVersion == version) != (version.endsWith('-SNAPSHOT') || version == '<unknown>')
4848
}
4949
}

src/test/groovy/net/kautler/command/api/CommandContextTest.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ class CommandContextTest extends Specification {
3636
def alias = randomUUID() as String
3737
def parameterString = randomUUID() as String
3838
Command command = Stub()
39+
3940
@Shared
4041
def additionalDataKey = randomUUID() as String
42+
4143
@Shared
4244
def additionalDataValue = randomUUID()
4345

0 commit comments

Comments
 (0)