diff --git a/buildSrc/src/main/kotlin/dev/stapler/detekt/JvmOnlyApiInCommonMainRule.kt b/buildSrc/src/main/kotlin/dev/stapler/detekt/JvmOnlyApiInCommonMainRule.kt index 0db944be3..04751e03d 100644 --- a/buildSrc/src/main/kotlin/dev/stapler/detekt/JvmOnlyApiInCommonMainRule.kt +++ b/buildSrc/src/main/kotlin/dev/stapler/detekt/JvmOnlyApiInCommonMainRule.kt @@ -20,8 +20,8 @@ import org.jetbrains.kotlin.psi.KtSimpleNameExpression * - `bytes.toString(Charsets.UTF_8)` → `bytes.decodeToString()` * - `content.toByteArray(Charsets.UTF_8)` → `content.encodeToByteArray()` * - * The rule fires on any `Charsets` name reference. JVM-only source sets (`jvmMain`, `jvmTest`, - * `androidMain`, `androidUnitTest`) are excluded via `detekt.yml` — they are valid hosts for + * The rule fires on any `Charsets` name reference. JVM-only source sets (`jvmCommonMain`, `jvmMain`, + * `jvmTest`, `androidMain`, `androidUnitTest`) are excluded via `detekt.yml` — they are valid hosts for * JVM-specific APIs. * * **Why types can't close this gap**: `Charsets` is a JVM stdlib class; there is no diff --git a/kmp/BUILD.bazel b/kmp/BUILD.bazel index 8c75c0624..8d0aab8c0 100644 --- a/kmp/BUILD.bazel +++ b/kmp/BUILD.bazel @@ -130,6 +130,7 @@ detekt_test( "//kmp/src/commonMain/kotlin:detekt_srcs", "//kmp/src/commonMain/kotlin/dev/stapler/stelekit/stats:detekt_srcs", "//kmp/src/iosMain/kotlin:detekt_srcs", + "//kmp/src/jvmCommonMain/kotlin:detekt_srcs", "//kmp/src/jvmMain/kotlin:detekt_srcs", ], baseline = "config/detekt/baseline.xml", diff --git a/kmp/build.gradle.kts b/kmp/build.gradle.kts index d36051100..e489b08ef 100644 --- a/kmp/build.gradle.kts +++ b/kmp/build.gradle.kts @@ -1280,6 +1280,7 @@ detekt { // Analyse all KMP source sets; generated SQLDelight code is excluded via config source.setFrom( "src/commonMain/kotlin", + "src/jvmCommonMain/kotlin", "src/jvmMain/kotlin", "src/androidMain/kotlin", "src/iosMain/kotlin", diff --git a/kmp/config/detekt/detekt.yml b/kmp/config/detekt/detekt.yml index ac43f52f8..e3241f0e2 100644 --- a/kmp/config/detekt/detekt.yml +++ b/kmp/config/detekt/detekt.yml @@ -33,7 +33,7 @@ stelekit: excludes: ['**/TypedLazyItems.kt', '**/*Test.kt', '**/test/**', '**/*Spec.kt'] JvmOnlyApiInCommonMain: active: true - excludes: ['**/jvmMain/**', '**/jvmTest/**', '**/androidMain/**', '**/androidUnitTest/**', + excludes: ['**/jvmCommonMain/**', '**/jvmMain/**', '**/jvmTest/**', '**/androidMain/**', '**/androidUnitTest/**', '**/iosMain/**', '**/buildSrc/**'] IndexWithoutAnalyze: active: true diff --git a/kmp/src/jvmCommonMain/kotlin/BUILD.bazel b/kmp/src/jvmCommonMain/kotlin/BUILD.bazel index 5cae42d45..b3deecc25 100644 --- a/kmp/src/jvmCommonMain/kotlin/BUILD.bazel +++ b/kmp/src/jvmCommonMain/kotlin/BUILD.bazel @@ -67,3 +67,9 @@ exports_files( glob(["**/*.kt"]), visibility = ["//kmp:__subpackages__"], ) + +filegroup( + name = "detekt_srcs", + srcs = glob(["**/*.kt"], allow_empty = False), + visibility = ["//kmp:__pkg__"], +) diff --git a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/db/libsql/LibsqlJni.kt b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/db/libsql/LibsqlJni.kt index 13704e32e..1ac75d76a 100644 --- a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/db/libsql/LibsqlJni.kt +++ b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/db/libsql/LibsqlJni.kt @@ -11,6 +11,7 @@ package dev.stapler.stelekit.db.libsql * - JVM desktop: extracted from classpath resource `native//libstelekit_libsql.{so,dylib,dll}` * - Android: loaded via [System.loadLibrary] from the APK's `jniLibs//` directory */ +@Suppress("TooManyFunctions") // one external fun per native entry point object LibsqlJni { const val SQLITE_BUSY_SNAPSHOT = 517 diff --git a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/git/BlockAwareConflict.kt b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/git/BlockAwareConflict.kt index 46f94438a..ca609fb31 100644 --- a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/git/BlockAwareConflict.kt +++ b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/git/BlockAwareConflict.kt @@ -80,6 +80,7 @@ private fun loadGitAttributes(repo: Repository, gitRelativePath: String): GitAtt val file = if (dir.isEmpty()) File(workTree, ".gitattributes") else File(File(workTree, dir), ".gitattributes") runCatching { if (file.isFile) GitAttributes.parse(file.readText(), dir) else null }.getOrNull() } + @Suppress("SpreadOperator") // combine() takes vararg; the list is one entry per directory level return GitAttributes.combine(*parsed.toTypedArray()) } @@ -108,7 +109,8 @@ private fun readConflictStages( } // A file conflicting for a non-content reason (binary, rename/rename, add/add without a // common base) won't carry all three stages — nothing for a text merge to work with. - if (local == null || remote == null || (base == null && !allowMissingBase)) return null + if (local == null || remote == null) return null + if (base == null && !allowMissingBase) return null fun blobText(entry: DirCacheEntry): String? = runCatching { repo.open(entry.objectId).bytes.toString(Charsets.UTF_8) }.getOrNull() diff --git a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/git/lfs/LfsBatchClient.kt b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/git/lfs/LfsBatchClient.kt index a55db1630..f99d42503 100644 --- a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/git/lfs/LfsBatchClient.kt +++ b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/git/lfs/LfsBatchClient.kt @@ -95,7 +95,7 @@ class LfsBatchClient( }.fold({ return it.left() }, { it }) val parsed = try { json.decodeFromString(response) - } catch (e: Exception) { + } catch (e: IllegalArgumentException) { // includes SerializationException return DomainError.GitError.FetchFailed("Git LFS returned an unreadable response").left() } parsed.objects.forEach { byOid[it.oid] = it } diff --git a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/performance/InstrumentedPageRepository.kt b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/performance/InstrumentedPageRepository.kt index 4ffe291a8..1f6658112 100644 --- a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/performance/InstrumentedPageRepository.kt +++ b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/performance/InstrumentedPageRepository.kt @@ -1,8 +1,6 @@ package dev.stapler.stelekit.performance import arrow.core.Either -import arrow.core.left -import arrow.core.right import dev.stapler.stelekit.error.DomainError import dev.stapler.stelekit.model.Page @@ -16,6 +14,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.CancellationException import kotlinx.datetime.LocalDate +@Suppress("TooManyFunctions") // one delegate per PageRepository method class InstrumentedPageRepository( private val delegate: PageRepository, private val tracer: Tracer diff --git a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/performance/InstrumentedSearchRepository.kt b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/performance/InstrumentedSearchRepository.kt index 54c8a7cfb..70c1231d1 100644 --- a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/performance/InstrumentedSearchRepository.kt +++ b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/performance/InstrumentedSearchRepository.kt @@ -1,8 +1,6 @@ package dev.stapler.stelekit.performance import arrow.core.Either -import arrow.core.left -import arrow.core.right import dev.stapler.stelekit.error.DomainError import dev.stapler.stelekit.model.Block @@ -13,7 +11,6 @@ import dev.stapler.stelekit.repository.DirectRepositoryWrite import dev.stapler.stelekit.repository.SearchRepository import dev.stapler.stelekit.repository.SearchRequest import dev.stapler.stelekit.repository.SearchResult -import io.opentelemetry.api.trace.StatusCode import io.opentelemetry.api.trace.Tracer import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map diff --git a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/performance/OtelSqlDelightExtensions.kt b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/performance/OtelSqlDelightExtensions.kt index 624f9c1b8..7d55370da 100644 --- a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/performance/OtelSqlDelightExtensions.kt +++ b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/performance/OtelSqlDelightExtensions.kt @@ -1,8 +1,6 @@ package dev.stapler.stelekit.performance import arrow.core.Either -import arrow.core.left -import arrow.core.right import dev.stapler.stelekit.error.DomainError import dev.stapler.stelekit.db.DatabaseWriteActor diff --git a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/platform/JvmFileSystemBase.kt b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/platform/JvmFileSystemBase.kt index 49314ce27..a32b189aa 100644 --- a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/platform/JvmFileSystemBase.kt +++ b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/platform/JvmFileSystemBase.kt @@ -12,6 +12,7 @@ import java.util.concurrent.ConcurrentHashMap /** * Base class for JVM file system implementations. */ +@Suppress("TooManyFunctions") // the shared half of the FileSystem interface abstract class JvmFileSystemBase { private val logger = Logger("FileSystem") companion object { diff --git a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/platform/download/ResumableDownload.kt b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/platform/download/ResumableDownload.kt index e4896e5e1..ef1d7eb25 100644 --- a/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/platform/download/ResumableDownload.kt +++ b/kmp/src/jvmCommonMain/kotlin/dev/stapler/stelekit/platform/download/ResumableDownload.kt @@ -3,7 +3,6 @@ package dev.stapler.stelekit.platform.download -import kotlinx.coroutines.CancellationException import kotlinx.coroutines.ensureActive import java.io.File import java.io.IOException @@ -68,8 +67,6 @@ object ResumableDownload { } } if (total > 0 && part.length() != total) throw IOException("Truncated download: ${part.length()} of $total bytes") - } catch (e: CancellationException) { - throw e } finally { connection.disconnect() }