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:
@@ -96,6 +96,7 @@ data class StatsReportDto(
|
||||
private const val MS_PER_SECOND = 1000L
|
||||
private const val SECONDS_PER_MINUTE = 60L
|
||||
private const val MINUTES_PER_HOUR = 60L
|
||||
private const val PERCENT_MULTIPLIER = 100.0
|
||||
|
||||
private fun humanDuration(ms: Long): String {
|
||||
if (ms <= 0L) return "0s"
|
||||
@@ -111,7 +112,7 @@ private fun humanDuration(ms: Long): String {
|
||||
}
|
||||
|
||||
private fun otherPct(report: StatsReportDto): Double =
|
||||
(100.0 - report.inferencePct - report.toolPct - report.approvalWaitPct).coerceAtLeast(0.0)
|
||||
(PERCENT_MULTIPLIER - report.inferencePct - report.toolPct - report.approvalWaitPct).coerceAtLeast(0.0)
|
||||
|
||||
fun renderStats(report: StatsReportDto): String {
|
||||
val lines = mutableListOf<String>()
|
||||
@@ -162,10 +163,10 @@ fun renderStats(report: StatsReportDto): String {
|
||||
val q = report.quality
|
||||
lines += "Signal quality"
|
||||
lines += " extraction: %d fetched, %d low-quality (%.0f%% clean)".format(
|
||||
Locale.ROOT, q.sourceFetches, q.lowQualityExtractions, q.extractionQualityRate * 100.0,
|
||||
Locale.ROOT, q.sourceFetches, q.lowQualityExtractions, q.extractionQualityRate * PERCENT_MULTIPLIER,
|
||||
)
|
||||
lines += " retrieval: %d kept, %d filtered (%.0f%% precision)".format(
|
||||
Locale.ROOT, q.retrievedHits, q.droppedHits, q.retrievalPrecision * 100.0,
|
||||
Locale.ROOT, q.retrievedHits, q.droppedHits, q.retrievalPrecision * PERCENT_MULTIPLIER,
|
||||
)
|
||||
lines += " brief drift: ${q.briefDriftCount} capability gaps: ${q.capabilityGapCount}"
|
||||
lines += ""
|
||||
|
||||
@@ -34,6 +34,9 @@ import kotlinx.serialization.json.put
|
||||
|
||||
private val taskJson = Json { ignoreUnknownKeys = true }
|
||||
|
||||
private const val TASK_ID_COLUMN_WIDTH = 14
|
||||
private const val TASK_STATUS_COLUMN_WIDTH = 12
|
||||
|
||||
/** Subset of the server's TaskResponse the CLI renders. Unknown fields are ignored. */
|
||||
@Serializable
|
||||
data class TaskRow(
|
||||
@@ -60,7 +63,9 @@ fun renderTaskList(tasks: List<TaskRow>): String {
|
||||
if (tasks.isEmpty()) return "no tasks"
|
||||
return tasks.joinToString("\n") { t ->
|
||||
val claim = t.claimant?.let { " @$it" }.orEmpty()
|
||||
"${t.id.padEnd(14)} ${t.status.padEnd(12)} ${t.title.orEmpty()}$claim".trimEnd()
|
||||
val id = t.id.padEnd(TASK_ID_COLUMN_WIDTH)
|
||||
val status = t.status.padEnd(TASK_STATUS_COLUMN_WIDTH)
|
||||
"$id $status ${t.title.orEmpty()}$claim".trimEnd()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,8 +229,10 @@ class TaskCreateCommand : TaskHttpCommand("create") {
|
||||
}
|
||||
val raw = resp.bodyAsText()
|
||||
when {
|
||||
resp.status == HttpStatusCode.Conflict ->
|
||||
System.err.println("Possible duplicate(s) — pass --force to create anyway:\n${renderTaskList(taskJson.decodeFromString(raw))}")
|
||||
resp.status == HttpStatusCode.Conflict -> {
|
||||
val dupes = renderTaskList(taskJson.decodeFromString(raw))
|
||||
System.err.println("Possible duplicate(s) — pass --force to create anyway:\n$dupes")
|
||||
}
|
||||
jsonOut() -> println(raw)
|
||||
else -> println("created ${taskJson.decodeFromString<TaskRow>(raw).id}")
|
||||
}
|
||||
@@ -250,7 +257,11 @@ class TaskCompleteCommand : TaskHttpCommand("complete") {
|
||||
|
||||
override fun run() = http { client ->
|
||||
val resp = client.post("${baseUrl()}/tasks/$id/complete")
|
||||
if (resp.status == HttpStatusCode.NotFound) System.err.println("No such task: $id") else println("completed $id")
|
||||
if (resp.status == HttpStatusCode.NotFound) {
|
||||
System.err.println("No such task: $id")
|
||||
} else {
|
||||
println("completed $id")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ class TaskRenderTest {
|
||||
val lines = out.lines()
|
||||
assertEquals(2, lines.size)
|
||||
assertTrue(lines[0].startsWith("auth-1"))
|
||||
assertTrue(lines[0].contains("IN_PROGRESS") && lines[0].contains("JWT refresh") && lines[0].contains("@claude-opus"))
|
||||
assertTrue(
|
||||
lines[0].contains("IN_PROGRESS") && lines[0].contains("JWT refresh") && lines[0].contains("@claude-opus"),
|
||||
)
|
||||
assertTrue(lines[1].contains("billing-3") && lines[1].contains("DONE"))
|
||||
}
|
||||
|
||||
@@ -38,7 +40,14 @@ class TaskRenderTest {
|
||||
fun `renderTaskDetail includes goal, criteria, links and notes`() {
|
||||
val out = renderTaskDetail(task)
|
||||
assertTrue(out.startsWith("task auth-1 [IN_PROGRESS] JWT refresh"))
|
||||
for (want in listOf("goal: users stay authenticated", "- rotates", "backend/auth/**", "adr-7 (IMPLEMENTS -> DOC)", "[AGENT] kickoff")) {
|
||||
val wants = listOf(
|
||||
"goal: users stay authenticated",
|
||||
"- rotates",
|
||||
"backend/auth/**",
|
||||
"adr-7 (IMPLEMENTS -> DOC)",
|
||||
"[AGENT] kickoff",
|
||||
)
|
||||
for (want in wants) {
|
||||
assertTrue(out.contains(want), "detail missing: $want")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user