Modern Apps git

← Modern-Apps.git

library-map: detekt clean (95 tests)

Commit
075fd12883ef07651e3b3f8b5be4febf61da1638
Author
Vayun Mathur <[email protected]>
When
2026-11-14 23:11 UTC (21 days ago)
Parents
6739b6b
Findings before: 9 (5 UndocumentedPublicClass warnings,
3 TooGenericExceptionCaught errors, 1 MaxLineLength error).
After: 0.

- Added KDoc for the LayerOptions/GestureOptions/OrnamentOptions
  preset companions, MapOptions itself, and the Projection
  companion (numeric guards).
- Wrapped the over-length VectorMap KDoc line.
- The three broad catches at the JNI/render-thread boundary keep
  catching Throwable with narrow
  @Suppress(TooGenericExceptionCaught) on create/frame/post only:
  the rule is genuinely wrong there - any native or arbitrary
  task failure must be logged and answered (0 / NONE / contained),
  never propagate and wedge the frame loop or kill the only
  render thread. Justification is in code comments at each site.

Verified: ./gradlew :library:map:detekt
:library:map:testDebugUnitTest :library:map:lint
--max-workers=32 all green (95 unit tests).

Diff

library/map/src/main/java/com/vayunmathur/library/map/LayerOptions.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/LayerOptions.kt b/library/map/src/main/java/com/vayunmathur/library/map/LayerOptions.ktindex b192a9b144..2b6e517bda 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/LayerOptions.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/LayerOptions.kt@@ -83,6 +83,7 @@ data class LayerOptions(      */     val safety: Boolean = false, ) {+    /** Preset layer combinations: basemap-only and all optional layers. */     companion object {         /** The default: basemap only. */         val None = LayerOptions()
library/map/src/main/java/com/vayunmathur/library/map/MapNativeLink.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/MapNativeLink.kt b/library/map/src/main/java/com/vayunmathur/library/map/MapNativeLink.ktindex 47871ac29f..ecfcfaef2f 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/MapNativeLink.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/MapNativeLink.kt@@ -69,7 +69,9 @@ internal class MapNativeLink {      * the main thread, unless a [destroy] overtook it. [cacheDir] and [localPath] are resolved      * on the render thread because both touch the disk.      */-    @Suppress("LongParameterList")+    // Broad catch is the contract at this JNI boundary: any native or path-resolution+    // failure must answer 0 (failed start), never propagate and wedge the frame loop.+    @Suppress("LongParameterList", "TooGenericExceptionCaught")     fun create(         surface: Surface,         cacheDir: () -> String,@@ -126,6 +128,9 @@ internal class MapNativeLink {      * Draw one frame on the render thread from a snapshot read on the main thread; [onDone]      * gets the result back on the main thread, unless a [destroy] overtook it.      */+    // Broad catch is the contract at this JNI boundary: every dispatched frame must+    // answer, so any native failure answers "not drawn" instead of hanging the loop.+    @Suppress("TooGenericExceptionCaught")     fun frame(         snapshot: FrameSnapshot,         density: Float,
library/map/src/main/java/com/vayunmathur/library/map/MapOptions.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/MapOptions.kt b/library/map/src/main/java/com/vayunmathur/library/map/MapOptions.ktindex 91e9ddb1ce..5965d0983e 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/MapOptions.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/MapOptions.kt@@ -10,6 +10,7 @@ data class GestureOptions(     val isRotateEnabled: Boolean = true,     val isTiltEnabled: Boolean = true, ) {+    /** Preset gesture configurations for common embedding scenarios. */     companion object {         /** Pan + zoom, rotation locked north-up (the old default behaviour). */         val RotationLocked =@@ -55,11 +56,13 @@ internal val GestureOptions.isTiltDisabled: Boolean data class OrnamentOptions(     val isAttributionEnabled: Boolean = true, ) {+    /** Preset ornament configurations. */     companion object {         val AllDisabled = OrnamentOptions(isAttributionEnabled = false)     } } +/** Bundles the gesture, ornament and layer options a [VectorMap] is created with. */ data class MapOptions(     val gestureOptions: GestureOptions = GestureOptions(),     val ornamentOptions: OrnamentOptions = OrnamentOptions(),
library/map/src/main/java/com/vayunmathur/library/map/MapRenderThread.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/MapRenderThread.kt b/library/map/src/main/java/com/vayunmathur/library/map/MapRenderThread.ktindex 0b2029a79e..58f5381663 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/MapRenderThread.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/MapRenderThread.kt@@ -64,6 +64,9 @@ internal object MapRenderThread {     private var thread: Thread? = null      /** Run [task] on the render thread after everything already queued. Never blocks. */+    // Tasks are arbitrary renderer lambdas: any failure must be contained and logged,+    // never kill the only render thread. No specific exception type exists to catch.+    @Suppress("TooGenericExceptionCaught")     fun post(task: () -> Unit) {         executor.execute {             thread = Thread.currentThread()
library/map/src/main/java/com/vayunmathur/library/map/Projection.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/Projection.kt b/library/map/src/main/java/com/vayunmathur/library/map/Projection.ktindex 6822d4ebdd..179888d23b 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/Projection.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/Projection.kt@@ -339,6 +339,7 @@ class Projection internal constructor(      */     fun pickMarker(xDp: Float, yDp: Float): Long = markerPick?.invoke(xDp, yDp) ?: 0L +    /** Numeric guards shared by the projection paths. */     companion object {         private const val OFF_SCREEN_DP = -1e5f         private const val MIN_PERSPECTIVE_DENOM = 1e-6
library/map/src/main/java/com/vayunmathur/library/map/VectorMap.kt
diff --git a/library/map/src/main/java/com/vayunmathur/library/map/VectorMap.kt b/library/map/src/main/java/com/vayunmathur/library/map/VectorMap.ktindex e1f1ad5a87..6ea49b3b21 100644--- a/library/map/src/main/java/com/vayunmathur/library/map/VectorMap.kt+++ b/library/map/src/main/java/com/vayunmathur/library/map/VectorMap.kt@@ -48,7 +48,8 @@ internal val MapOnlineDefault: StateFlow<Boolean> = OnlineAlways  * The vector map.  *  * Renders the planet-scale single-file `planet5.mamaps` archive- * (`data.maproj.org/planet5.mamaps`: v10 header, dictionary-zstd v11 bodies, 10 layers, 128-byte header; planet4 v9 archives still read) with our own+ * (`data.maproj.org/planet5.mamaps`: v10 header, dictionary-zstd v11 bodies,+ * 10 layers, 128-byte header; planet4 v9 archives still read) with our own  * Vulkan renderer. No third-party tile CDN and no API key, which is the whole point:  * watermarked, and that broke the basemap in five apps (#615).  *