refactor(detekt): extract magic-number constants, wrap long lines, drop legit suppressions

Mechanical detekt cleanup across apps/core/infrastructure (behavior-preserving):
- MagicNumber 62->10: named constants + removed 'legit' MagicNumber suppressions
  (Tier level from ordinal, ReplayInferenceProvider CHARS_PER_TOKEN, ConfigLoader
  DEFAULT_* consts, capability scores, HTTP ranges, column widths, etc.)
- MaxLineLength cut to ~0 in production modules (line wraps, no logic change)
- Dropped one dead parameter (ConfigLoader.parseArray lineNum)

Structural findings (ReturnCount/LongMethod/Complexity/LargeClass) left for a
deliberate decomposition pass. Full build + detekt gate green.
This commit is contained in:
2026-07-12 23:12:28 +04:00
parent 135a34eb2f
commit aee2e67c66
70 changed files with 1034 additions and 236 deletions
@@ -3,14 +3,16 @@ package com.correx.core.approvals
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Suppress("MagicNumber")
@Serializable
enum class Tier(val level: Int) {
@SerialName("T0") T0(0),
@SerialName("T1") T1(1),
@SerialName("T2") T2(2),
@SerialName("T3") T3(3),
@SerialName("T4") T4(4)
enum class Tier {
@SerialName("T0") T0,
@SerialName("T1") T1,
@SerialName("T2") T2,
@SerialName("T3") T3,
@SerialName("T4") T4;
/** Escalation level, ordered T0 < T1 < … < T4. Derived from declaration order — no magic numbers. */
val level: Int get() = ordinal
}
fun Tier.isAtLeast(other: Tier): Boolean = this.level >= other.level
@@ -28,6 +28,10 @@ class ArtifactRepairEventSerializationTest {
@Test
fun `ArtifactRepairFailed round-trips`() {
roundTrip(ArtifactRepairFailedEvent(ArtifactId("a"), "UNSAFE", "Abort", "path escapes", SessionId("s"), StageId("st")))
roundTrip(
ArtifactRepairFailedEvent(
ArtifactId("a"), "UNSAFE", "Abort", "path escapes", SessionId("s"), StageId("st"),
),
)
}
}
@@ -14,7 +14,11 @@ class PlanLintCompletedEventSerializationTest {
sessionId = SessionId("sess-1"),
candidateId = "freestyle-sess-1",
hardFailures = listOf(
PlanLintFinding(code = "unproduced_need", stageId = "implement", detail = "needs 'design', produced by no stage"),
PlanLintFinding(
code = "unproduced_need",
stageId = "implement",
detail = "needs 'design', produced by no stage",
),
PlanLintFinding(code = "trap_state", stageId = "loop", detail = "no path to 'done'"),
),
softFindings = listOf(
@@ -44,7 +44,11 @@ class RepoKnowledgeRetrievedEventSerializationTest {
query = "context builder",
hits = listOf(
RepoKnowledgeHit(path = "core/context/ContextBuilder.kt", text = "class ContextBuilder", score = 0.95f),
RepoKnowledgeHit(path = "core/context/DefaultContextBuilder.kt", text = "class DefaultContextBuilder", score = 0.88f),
RepoKnowledgeHit(
path = "core/context/DefaultContextBuilder.kt",
text = "class DefaultContextBuilder",
score = 0.88f,
),
),
)
assertEquals(sample, eventJson.decodeFromString(EventPayload.serializer(),
@@ -28,7 +28,8 @@ class RepoMapComputedEventSerializationTest {
@Test
fun `RepoMapComputedEvent without stateKey field decodes with null`() {
val json = """{"type":"RepoMapComputed","sessionId":"s","repoRoot":"/repo","entries":[],"computedAt":"2026-06-11T00:00:00Z"}"""
val json = """{"type":"RepoMapComputed","sessionId":"s","repoRoot":"/repo",""" +
""""entries":[],"computedAt":"2026-06-11T00:00:00Z"}"""
val decoded = eventJson.decodeFromString(EventPayload.serializer(), json) as RepoMapComputedEvent
assertNull(decoded.stateKey)
}
@@ -23,7 +23,12 @@ class ToolCallAssessedEventSerializationTest {
observations = listOf(
ToolCallObservation(
ruleCode = "PATH_CONTAINMENT",
facts = mapOf("path" to "/tmp/x", "exists" to "false", "inWorkspace" to "false", "privileged" to "false"),
facts = mapOf(
"path" to "/tmp/x",
"exists" to "false",
"inWorkspace" to "false",
"privileged" to "false",
),
),
),
disposition = RiskAction.PROMPT_USER,