From 8350ff9fe44194122340fdcd235764ef9dee6378 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 May 2026 15:36:44 -0300 Subject: [PATCH 1/2] build(deps): bump org.jlleitschuh.gradle.ktlint from 12.1.2 to 14.2.0 --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 5bf74e1..965ddff 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,7 @@ plugins { kotlin("jvm") version "2.3.21" apply false kotlin("plugin.serialization") version "2.3.21" apply false id("org.jetbrains.kotlinx.kover") version "0.9.8" apply false - id("org.jlleitschuh.gradle.ktlint") version "12.1.2" apply false + id("org.jlleitschuh.gradle.ktlint") version "14.2.0" apply false id("io.gitlab.arturbosch.detekt") version "1.23.8" apply false } From 530770853b16722ef271ec9c14bc27249dc33a27 Mon Sep 17 00:00:00 2001 From: HectorIFC Date: Fri, 22 May 2026 15:40:23 -0300 Subject: [PATCH 2/2] build: adapt to ktlint 14 lint rules ktlint 14 introduces two new standard rules that fire on the existing code: - `class-signature` would move every Kotest `class XxxTest : StringSpec({...})` supertype onto a new line, re-indenting ~300+ lines across 12 spec files for pure cosmetics. Disabled via `.editorconfig`; the existing 120-char `max_line_length` already keeps headers readable. - `function-expression-body` is genuinely idiomatic Kotlin (collapse `fun f(): X { return expr }` into `fun f(): X = expr`). Applied to the three call sites that triggered it: EmbeddingTable.get(IntArray), CreateCommand.buildInitializer, and the embeddingsWithSeed test helper. After these changes `./gradlew ktlintCheck detekt build koverVerify` is green on ktlint 14.2.0. Co-Authored-By: Claude Opus 4.7 --- .editorconfig | 5 +++ .../kotlin/dev/mosaic/cli/CreateCommand.kt | 32 +++++++++---------- .../main/kotlin/dev/mosaic/EmbeddingTable.kt | 4 +-- .../kotlin/dev/mosaic/EmbeddingTableTest.kt | 12 +++---- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/.editorconfig b/.editorconfig index 7258cad..95a71df 100644 --- a/.editorconfig +++ b/.editorconfig @@ -14,6 +14,11 @@ ktlint_code_style = intellij_idea # Allow trailing commas in function parameters and arguments ij_kotlin_allow_trailing_comma = true ij_kotlin_allow_trailing_comma_on_call_site = true +# Disable class-signature rule (added in ktlint 14). The default forces multi-line +# class headers when the supertype call has a body (e.g. `class T : StringSpec({...})`). +# That would re-indent every Kotest spec across 300+ lines for pure cosmetics — +# not worth it. Existing `max_line_length = 120` already keeps headers readable. +ktlint_standard_class-signature = disabled [*.md] trim_trailing_whitespace = false diff --git a/mosaic-cli/src/main/kotlin/dev/mosaic/cli/CreateCommand.kt b/mosaic-cli/src/main/kotlin/dev/mosaic/cli/CreateCommand.kt index 77d6ec7..63a478f 100644 --- a/mosaic-cli/src/main/kotlin/dev/mosaic/cli/CreateCommand.kt +++ b/mosaic-cli/src/main/kotlin/dev/mosaic/cli/CreateCommand.kt @@ -38,24 +38,22 @@ internal object CreateCommand { return 0 } - private fun buildInitializer(name: String, dim: Int, seed: Long, parsed: Args): Initializer { - return when (name) { - "uniform" -> { - val bound = parsed.optionalFloat("--bound") - if (bound != null) Initializer.uniform(bound, seed) else Initializer.uniformDefault(seed) - } - "xavier" -> Initializer.xavier(fanIn = dim, fanOut = dim, seed = seed) - "he" -> Initializer.he(fanIn = dim, seed = seed) - "zeros" -> Initializer.zeros() - "constant" -> { - val value = parsed.optionalFloat("--value") - ?: throw UsageError("Initializer 'constant' requires --value") - Initializer.constant(value) - } - else -> throw UsageError( - "Unknown initializer '$name'. Valid: uniform, xavier, he, zeros, constant", - ) + private fun buildInitializer(name: String, dim: Int, seed: Long, parsed: Args): Initializer = when (name) { + "uniform" -> { + val bound = parsed.optionalFloat("--bound") + if (bound != null) Initializer.uniform(bound, seed) else Initializer.uniformDefault(seed) } + "xavier" -> Initializer.xavier(fanIn = dim, fanOut = dim, seed = seed) + "he" -> Initializer.he(fanIn = dim, seed = seed) + "zeros" -> Initializer.zeros() + "constant" -> { + val value = parsed.optionalFloat("--value") + ?: throw UsageError("Initializer 'constant' requires --value") + Initializer.constant(value) + } + else -> throw UsageError( + "Unknown initializer '$name'. Valid: uniform, xavier, he, zeros, constant", + ) } private fun help(): String = """ diff --git a/mosaic-core/src/main/kotlin/dev/mosaic/EmbeddingTable.kt b/mosaic-core/src/main/kotlin/dev/mosaic/EmbeddingTable.kt index 0fb29be..9614592 100644 --- a/mosaic-core/src/main/kotlin/dev/mosaic/EmbeddingTable.kt +++ b/mosaic-core/src/main/kotlin/dev/mosaic/EmbeddingTable.kt @@ -41,9 +41,7 @@ public class EmbeddingTable internal constructor( } /** Returns copies of the rows at the given [ids], in order. */ - public fun get(ids: IntArray): Array { - return Array(ids.size) { idx -> get(ids[idx]) } - } + public fun get(ids: IntArray): Array = Array(ids.size) { idx -> get(ids[idx]) } /** Writes [vector] into the row at [id]. The source array is copied; the caller may mutate it freely afterwards. */ public fun set(id: Int, vector: FloatArray) { diff --git a/mosaic-core/src/test/kotlin/dev/mosaic/EmbeddingTableTest.kt b/mosaic-core/src/test/kotlin/dev/mosaic/EmbeddingTableTest.kt index 91f5a80..af0c7a5 100644 --- a/mosaic-core/src/test/kotlin/dev/mosaic/EmbeddingTableTest.kt +++ b/mosaic-core/src/test/kotlin/dev/mosaic/EmbeddingTableTest.kt @@ -127,10 +127,8 @@ class EmbeddingTableTest : StringSpec({ } }) -private fun embeddingsWithSeed(vocabSize: Int, embeddingDim: Int, seed: Long): EmbeddingTable { - return EmbeddingTable.create( - vocabSize = vocabSize, - embeddingDim = embeddingDim, - initializer = Initializer.uniform(bound = 1f, seed = seed), - ) -} +private fun embeddingsWithSeed(vocabSize: Int, embeddingDim: Int, seed: Long): EmbeddingTable = EmbeddingTable.create( + vocabSize = vocabSize, + embeddingDim = embeddingDim, + initializer = Initializer.uniform(bound = 1f, seed = seed), +)