Skip to content

Commit 533262d

Browse files
committed
chore: Re-enable Detekt except in CI
1 parent e5efa22 commit 533262d

File tree

4 files changed

+24
-18
lines changed

4 files changed

+24
-18
lines changed

buildSrc/src/main/groovy/au.com.dius.pact.kotlin-common-conventions.gradle

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ plugins {
33
id 'org.jetbrains.kotlin.jvm'
44

55
id 'groovy'
6-
// id "io.gitlab.arturbosch.detekt" TODO: Detekt does not support JDK 23 yet
6+
// TODO: Detekt does not support JDK 23 yet
7+
id "io.gitlab.arturbosch.detekt" apply false
78
id 'codenarc'
89
}
910

@@ -112,6 +113,8 @@ codenarcTest {
112113
}
113114

114115
// TODO: Detekt does not support JDK 23 yet
115-
//detekt {
116-
// config = files(rootProject.file("config/detekt-config.yml"))
117-
//}
116+
if (System.getenv('CI') == null) {
117+
detekt {
118+
config = files(rootProject.file("config/detekt-config.yml"))
119+
}
120+
}

core/model/src/main/kotlin/au/com/dius/pact/core/model/matchingrules/MatchingRuleCategory.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
package au.com.dius.pact.core.model.matchingrules
22

3-
import au.com.dius.pact.core.model.*
3+
import au.com.dius.pact.core.model.PactSpecVersion
4+
import au.com.dius.pact.core.model.PathToken
5+
import au.com.dius.pact.core.model.atLeast
46
import au.com.dius.pact.core.model.generators.Generator
57
import au.com.dius.pact.core.support.json.JsonValue
6-
import io.github.oshai.kotlinlogging.KLogging
7-
import java.util.Comparator
8+
import io.github.oshai.kotlinlogging.KotlinLogging
89
import java.util.function.Predicate
910

11+
private val logger = KotlinLogging.logger {}
12+
1013
/**
1114
* Matching rules category
1215
*/
1316
data class MatchingRuleCategory @JvmOverloads constructor(
1417
val name: String,
1518
var matchingRules: MutableMap<String, MatchingRuleGroup> = mutableMapOf()
1619
) {
17-
18-
companion object : KLogging()
19-
2020
/**
2121
* Add a rule by key to the given category
2222
*/

core/model/src/main/kotlin/au/com/dius/pact/core/model/matchingrules/MatchingRules.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ import au.com.dius.pact.core.support.Either
1414
import au.com.dius.pact.core.support.Json
1515
import au.com.dius.pact.core.support.json.JsonValue
1616
import au.com.dius.pact.core.support.json.map
17-
import io.github.oshai.kotlinlogging.KLogging
17+
import io.github.oshai.kotlinlogging.KotlinLogging
1818
import java.lang.RuntimeException
1919

20+
private val logger = KotlinLogging.logger {}
21+
2022
/**
2123
* Logic to use to combine rules
2224
*/
@@ -63,7 +65,7 @@ interface MatchingRule {
6365
*/
6466
val attributes: Map<String, JsonValue>
6567

66-
companion object : KLogging() {
68+
companion object {
6769
private const val MATCH = "match"
6870
private const val MIN = "min"
6971
private const val MAX = "max"
@@ -85,12 +87,12 @@ interface MatchingRule {
8587
j.has(TIME) -> TimeMatcher(j[TIME].asString()!!)
8688
j.has(DATE) -> DateMatcher(j[DATE].asString()!!)
8789
else -> {
88-
MatchingRuleGroup.logger.warn { "Unrecognised matcher definition $j, defaulting to equality matching" }
90+
logger.warn { "Unrecognised matcher definition $j, defaulting to equality matching" }
8991
EqualsMatcher
9092
}
9193
}
9294
} else {
93-
MatchingRuleGroup.logger.warn { "Unrecognised matcher definition $json, defaulting to equality matching" }
95+
logger.warn { "Unrecognised matcher definition $json, defaulting to equality matching" }
9496
EqualsMatcher
9597
}
9698
}
@@ -108,7 +110,7 @@ interface MatchingRule {
108110
"integer" -> NumberTypeMatcher(NumberTypeMatcher.NumberType.INTEGER)
109111
"decimal" -> NumberTypeMatcher(NumberTypeMatcher.NumberType.DECIMAL)
110112
"real" -> {
111-
MatchingRuleGroup.logger.warn { "The 'real' type matcher is deprecated, use 'decimal' instead" }
113+
logger.warn { "The 'real' type matcher is deprecated, use 'decimal' instead" }
112114
NumberTypeMatcher(NumberTypeMatcher.NumberType.DECIMAL)
113115
}
114116
MIN -> MinTypeMatcher(values[MIN].asNumber()!!.toInt())
@@ -194,7 +196,7 @@ interface MatchingRule {
194196
EachValueMatcher(definition)
195197
}
196198
else -> {
197-
MatchingRuleGroup.logger.warn { "Unrecognised matcher ${values[MATCH]}, defaulting to equality matching" }
199+
logger.warn { "Unrecognised matcher ${values[MATCH]}, defaulting to equality matching" }
198200
EqualsMatcher
199201
}
200202
}
@@ -676,7 +678,7 @@ data class MatchingRuleGroup @JvmOverloads constructor(
676678
return rules.any { matchers.contains(it.javaClass) }
677679
}
678680

679-
companion object : KLogging() {
681+
companion object {
680682
@JvmStatic
681683
fun fromJson(json: JsonValue): MatchingRuleGroup {
682684
var ruleLogic = RuleLogic.AND
@@ -691,7 +693,7 @@ data class MatchingRuleGroup @JvmOverloads constructor(
691693
ruleLogic = RuleLogic.valueOf(value)
692694
}
693695
} catch (e: IllegalArgumentException) {
694-
logger.warn { "${groupJson["combine"]} is not a valid matcher rule logic value" }
696+
logger.warn { "${groupJson["combine"]} is not a valid matcher rule logic value: ${e.message}" }
695697
}
696698
}
697699

core/model/src/main/kotlin/au/com/dius/pact/core/model/messaging/Message.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class Message @JvmOverloads constructor(
169169
}
170170
}
171171

172+
@Suppress("SwallowedException")
172173
private fun tryParseKafkaSchemaRegistryMagicBytes(): String {
173174
return try {
174175
parseKafkaSchemaRegistryMagicBytes()

0 commit comments

Comments
 (0)