Skip to content

Commit 20b1864

Browse files
jpicklykclaude
andauthored
style: fix ktlint multiline-expression-wrapping and string-template violations (#94)
Auto-formatted via ktlintFormat. Fixes CI lint check failures introduced in v2.5.2 refactoring commits. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c9f41f6 commit 20b1864

9 files changed

Lines changed: 234 additions & 202 deletions

File tree

current/src/main/kotlin/io/github/jpicklyk/mcptask/current/application/service/SchemaEntryJsonBuilder.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ fun buildExpectedNotesJson(
6060
*
6161
* @param schema Schema entries, or null if no schema matches
6262
*/
63-
fun buildSchemaResponseFields(
64-
schema: List<NoteSchemaEntry>?
65-
): SchemaResponseFields =
63+
fun buildSchemaResponseFields(schema: List<NoteSchemaEntry>?): SchemaResponseFields =
6664
SchemaResponseFields(
6765
schemaMatch = schema != null,
6866
expectedNotes = buildExpectedNotesJson(schema)

current/src/main/kotlin/io/github/jpicklyk/mcptask/current/application/tools/compound/CreateWorkTreeTool.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,10 @@ Atomically create a hierarchical work tree: root item, child items, dependencies
352352
val idToRef = treeResult.refToId.entries.associate { (ref, id) -> id to ref }
353353

354354
val rootResultItem = treeResult.items.first()
355-
val rootSchemaFields = buildSchemaResponseFields(
356-
context.noteSchemaService().getSchemaForTags(rootResultItem.tagList())
357-
)
355+
val rootSchemaFields =
356+
buildSchemaResponseFields(
357+
context.noteSchemaService().getSchemaForTags(rootResultItem.tagList())
358+
)
358359
val rootJson =
359360
buildJsonObject {
360361
put("id", JsonPrimitive(rootResultItem.id.toString()))
@@ -370,9 +371,10 @@ Atomically create a hierarchical work tree: root item, child items, dependencies
370371
JsonArray(
371372
treeResult.items.drop(1).map { item ->
372373
val ref = idToRef[item.id] ?: "unknown"
373-
val childSchemaFields = buildSchemaResponseFields(
374-
context.noteSchemaService().getSchemaForTags(item.tagList())
375-
)
374+
val childSchemaFields =
375+
buildSchemaResponseFields(
376+
context.noteSchemaService().getSchemaForTags(item.tagList())
377+
)
376378
buildJsonObject {
377379
put("ref", JsonPrimitive(ref))
378380
put("id", JsonPrimitive(item.id.toString()))

current/src/main/kotlin/io/github/jpicklyk/mcptask/current/application/tools/workflow/AdvanceItemTool.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,12 @@ Trigger-based role transitions for WorkItems with validation, cascade detection,
454454
val existingKeys = notesByKey.keys
455455

456456
// Build expectedNotes: schema entries matching the new role (tool-specific, includes "exists")
457-
expectedNotesJson = buildExpectedNotesJson(
458-
schema = schema,
459-
existingNoteKeys = existingKeys,
460-
filterRole = targetRole
461-
)
457+
expectedNotesJson =
458+
buildExpectedNotesJson(
459+
schema = schema,
460+
existingNoteKeys = existingKeys,
461+
filterRole = targetRole
462+
)
462463

463464
// Use shared PhaseNoteContext for guidancePointer and noteProgress
464465
val phaseContext = computePhaseNoteContext(targetRole, schema, notesByKey)

current/src/main/kotlin/io/github/jpicklyk/mcptask/current/application/tools/workflow/GetContextTool.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,12 @@ Parameters:
162162

163163
// Build schema list with exists/filled status
164164
val filledKeys = notes.filter { it.body.isNotBlank() }.map { it.key }.toSet()
165-
val schemaEntriesArray = buildExpectedNotesJson(
166-
schema = schema,
167-
existingNoteKeys = notesByKey.keys,
168-
filledNoteKeys = filledKeys
169-
)
165+
val schemaEntriesArray =
166+
buildExpectedNotesJson(
167+
schema = schema,
168+
existingNoteKeys = notesByKey.keys,
169+
filledNoteKeys = filledKeys
170+
)
170171

171172
// Gate status for current phase — uses shared computation
172173
val phaseContext = computePhaseNoteContext(item.role, schema, notesByKey)

current/src/main/kotlin/io/github/jpicklyk/mcptask/current/infrastructure/config/YamlNoteSchemaService.kt

Lines changed: 37 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -67,34 +67,38 @@ class YamlNoteSchemaService(
6767
return SchemaLoadResult(emptyMap(), warnings)
6868
}
6969

70-
val schemas = try {
71-
val yaml = Yaml()
72-
FileReader(configPath.toFile()).use { reader ->
73-
val root = yaml.load<Map<String, Any>>(reader)
74-
?: return@use emptyMap<String, List<NoteSchemaEntry>>()
75-
76-
if (!root.containsKey("note_schemas")) {
77-
warnings.add("Config file is missing 'note_schemas' key; no schemas loaded")
78-
return@use emptyMap()
79-
}
80-
81-
val noteSchemas = root["note_schemas"] as? Map<String, Any>
82-
?: return@use emptyMap<String, List<NoteSchemaEntry>>()
70+
val schemas =
71+
try {
72+
val yaml = Yaml()
73+
FileReader(configPath.toFile()).use { reader ->
74+
val root =
75+
yaml.load<Map<String, Any>>(reader)
76+
?: return@use emptyMap<String, List<NoteSchemaEntry>>()
77+
78+
if (!root.containsKey("note_schemas")) {
79+
warnings.add("Config file is missing 'note_schemas' key; no schemas loaded")
80+
return@use emptyMap()
81+
}
8382

84-
noteSchemas.entries.associate { (schemaName, rawEntries) ->
85-
val entryList = rawEntries as? List<Map<String, Any>> ?: emptyList()
86-
val entries = entryList.mapIndexedNotNull { index, raw ->
87-
parseEntry(raw, schemaName, index, warnings)
83+
val noteSchemas =
84+
root["note_schemas"] as? Map<String, Any>
85+
?: return@use emptyMap<String, List<NoteSchemaEntry>>()
86+
87+
noteSchemas.entries.associate { (schemaName, rawEntries) ->
88+
val entryList = rawEntries as? List<Map<String, Any>> ?: emptyList()
89+
val entries =
90+
entryList.mapIndexedNotNull { index, raw ->
91+
parseEntry(raw, schemaName, index, warnings)
92+
}
93+
schemaName to entries
8894
}
89-
schemaName to entries
9095
}
96+
} catch (e: Exception) {
97+
val msg = "Failed to load note schemas from '$configPath': ${e.message}"
98+
warnings.add(msg)
99+
logger.warn(msg)
100+
emptyMap()
91101
}
92-
} catch (e: Exception) {
93-
val msg = "Failed to load note schemas from '${configPath}': ${e.message}"
94-
warnings.add(msg)
95-
logger.warn(msg)
96-
emptyMap()
97-
}
98102

99103
val totalEntries = schemas.values.sumOf { it.size }
100104
warnings.forEach { w -> logger.warn(w) }
@@ -138,14 +142,15 @@ class YamlNoteSchemaService(
138142
}
139143

140144
val requiredRaw = raw["required"]
141-
val required = if (requiredRaw != null && requiredRaw !is Boolean) {
142-
warnings.add(
143-
"Schema '$schemaName' entry (key='$key') has non-boolean 'required' value '$requiredRaw'; defaulting to false"
144-
)
145-
false
146-
} else {
147-
requiredRaw as? Boolean ?: false
148-
}
145+
val required =
146+
if (requiredRaw != null && requiredRaw !is Boolean) {
147+
warnings.add(
148+
"Schema '$schemaName' entry (key='$key') has non-boolean 'required' value '$requiredRaw'; defaulting to false"
149+
)
150+
false
151+
} else {
152+
requiredRaw as? Boolean ?: false
153+
}
149154

150155
val description = raw["description"] as? String ?: ""
151156
val guidance = raw["guidance"] as? String

current/src/test/kotlin/io/github/jpicklyk/mcptask/current/application/service/NoteSchemaServiceTest.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class NoteSchemaServiceTest {
3434
// --- Gap M8: default method hasReviewPhase on NoOpNoteSchemaService ---
3535

3636
@Test
37-
fun `NoOp hasReviewPhase default method returns false via getSchemaForTags returning null`(): Unit {
37+
fun `NoOp hasReviewPhase default method returns false via getSchemaForTags returning null`() {
3838
// The hasReviewPhase default method on NoteSchemaService calls getSchemaForTags and
3939
// checks if any entry has role=REVIEW. When getSchemaForTags returns null (as NoOp does),
4040
// the elvis operator returns false. This test verifies the default method contract.
@@ -43,12 +43,13 @@ class NoteSchemaServiceTest {
4343
}
4444

4545
@Test
46-
fun `NoOp returns null which causes hasReviewPhase to return false via default implementation`(): Unit {
46+
fun `NoOp returns null which causes hasReviewPhase to return false via default implementation`() {
4747
// Verify that a custom NoteSchemaService returning null also gets false from the default
4848
// hasReviewPhase — confirming the default method logic is correct.
49-
val customService = object : NoteSchemaService {
50-
override fun getSchemaForTags(tags: List<String>) = null
51-
}
49+
val customService =
50+
object : NoteSchemaService {
51+
override fun getSchemaForTags(tags: List<String>) = null
52+
}
5253
assertFalse(customService.hasReviewPhase(listOf("tag1")))
5354
assertFalse(customService.hasReviewPhase(emptyList()))
5455
}

0 commit comments

Comments
 (0)