Skip to content

Commit

Permalink
chore: Re-enable Detekt except in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Dec 2, 2024
1 parent e5efa22 commit 533262d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ plugins {
id 'org.jetbrains.kotlin.jvm'

id 'groovy'
// id "io.gitlab.arturbosch.detekt" TODO: Detekt does not support JDK 23 yet
// TODO: Detekt does not support JDK 23 yet
id "io.gitlab.arturbosch.detekt" apply false
id 'codenarc'
}

Expand Down Expand Up @@ -112,6 +113,8 @@ codenarcTest {
}

// TODO: Detekt does not support JDK 23 yet
//detekt {
// config = files(rootProject.file("config/detekt-config.yml"))
//}
if (System.getenv('CI') == null) {
detekt {
config = files(rootProject.file("config/detekt-config.yml"))
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package au.com.dius.pact.core.model.matchingrules

import au.com.dius.pact.core.model.*
import au.com.dius.pact.core.model.PactSpecVersion
import au.com.dius.pact.core.model.PathToken
import au.com.dius.pact.core.model.atLeast
import au.com.dius.pact.core.model.generators.Generator
import au.com.dius.pact.core.support.json.JsonValue
import io.github.oshai.kotlinlogging.KLogging
import java.util.Comparator
import io.github.oshai.kotlinlogging.KotlinLogging
import java.util.function.Predicate

private val logger = KotlinLogging.logger {}

/**
* Matching rules category
*/
data class MatchingRuleCategory @JvmOverloads constructor(
val name: String,
var matchingRules: MutableMap<String, MatchingRuleGroup> = mutableMapOf()
) {

companion object : KLogging()

/**
* Add a rule by key to the given category
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import au.com.dius.pact.core.support.Either
import au.com.dius.pact.core.support.Json
import au.com.dius.pact.core.support.json.JsonValue
import au.com.dius.pact.core.support.json.map
import io.github.oshai.kotlinlogging.KLogging
import io.github.oshai.kotlinlogging.KotlinLogging
import java.lang.RuntimeException

private val logger = KotlinLogging.logger {}

/**
* Logic to use to combine rules
*/
Expand Down Expand Up @@ -63,7 +65,7 @@ interface MatchingRule {
*/
val attributes: Map<String, JsonValue>

companion object : KLogging() {
companion object {
private const val MATCH = "match"
private const val MIN = "min"
private const val MAX = "max"
Expand All @@ -85,12 +87,12 @@ interface MatchingRule {
j.has(TIME) -> TimeMatcher(j[TIME].asString()!!)
j.has(DATE) -> DateMatcher(j[DATE].asString()!!)
else -> {
MatchingRuleGroup.logger.warn { "Unrecognised matcher definition $j, defaulting to equality matching" }
logger.warn { "Unrecognised matcher definition $j, defaulting to equality matching" }
EqualsMatcher
}
}
} else {
MatchingRuleGroup.logger.warn { "Unrecognised matcher definition $json, defaulting to equality matching" }
logger.warn { "Unrecognised matcher definition $json, defaulting to equality matching" }
EqualsMatcher
}
}
Expand All @@ -108,7 +110,7 @@ interface MatchingRule {
"integer" -> NumberTypeMatcher(NumberTypeMatcher.NumberType.INTEGER)
"decimal" -> NumberTypeMatcher(NumberTypeMatcher.NumberType.DECIMAL)
"real" -> {
MatchingRuleGroup.logger.warn { "The 'real' type matcher is deprecated, use 'decimal' instead" }
logger.warn { "The 'real' type matcher is deprecated, use 'decimal' instead" }
NumberTypeMatcher(NumberTypeMatcher.NumberType.DECIMAL)
}
MIN -> MinTypeMatcher(values[MIN].asNumber()!!.toInt())
Expand Down Expand Up @@ -194,7 +196,7 @@ interface MatchingRule {
EachValueMatcher(definition)
}
else -> {
MatchingRuleGroup.logger.warn { "Unrecognised matcher ${values[MATCH]}, defaulting to equality matching" }
logger.warn { "Unrecognised matcher ${values[MATCH]}, defaulting to equality matching" }
EqualsMatcher
}
}
Expand Down Expand Up @@ -676,7 +678,7 @@ data class MatchingRuleGroup @JvmOverloads constructor(
return rules.any { matchers.contains(it.javaClass) }
}

companion object : KLogging() {
companion object {
@JvmStatic
fun fromJson(json: JsonValue): MatchingRuleGroup {
var ruleLogic = RuleLogic.AND
Expand All @@ -691,7 +693,7 @@ data class MatchingRuleGroup @JvmOverloads constructor(
ruleLogic = RuleLogic.valueOf(value)
}
} catch (e: IllegalArgumentException) {
logger.warn { "${groupJson["combine"]} is not a valid matcher rule logic value" }
logger.warn { "${groupJson["combine"]} is not a valid matcher rule logic value: ${e.message}" }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class Message @JvmOverloads constructor(
}
}

@Suppress("SwallowedException")
private fun tryParseKafkaSchemaRegistryMagicBytes(): String {
return try {
parseKafkaSchemaRegistryMagicBytes()
Expand Down

0 comments on commit 533262d

Please sign in to comment.