Clean up lint/LSP across gateway, Android, and desktop (alpha -> stable)

Gateway (gateway-plugin/):
- Fix interactive_setup broken imports: print helpers were imported from the
  wrong hermes module (hermes_cli.config instead of hermes_cli.cli_output) plus
  a non-existent print_code; the try/except swallowed the ImportError so
  `hermes gateway setup` for android always bailed out early.
- Fix release_scoped_lock type error (str | None passed where str required).
- Rewrite empty `except: pass` blocks as contextlib.suppress with rationale.
- Restructure two ambiguous ws_server try blocks (hello-auth, frame loop).
- Ruff cleanup: type annotations, import sorting, line wrapping, magic values
  -> named constants, `raise ... from e`, complexity. Add gateway-plugin/ruff.toml.
- Add pyrightconfig.json so the Python LSP resolves hermes-runtime imports.
- Suppress verified false positives inline (parameterized SQL, column-name
  "secrets", hermes-generated media path).

Android (app/androidApp + app/shared):
- Consolidate launcher icons into a single mipmap-anydpi (minSdk 29 >= 26) with
  the monochrome layer; clears ObsoleteSdkInt + MonochromeLauncherIcon.
- Bump core-splashscreen 1.0.1 -> 1.2.0; pin targetSdk 34 (deliberate).
- Suppress verified findings inline (LAN ws:// default, correct GCM IV usage).

Desktop (app/desktopApp):
- Move the desktop to a Java 21 runtime (org.gradle.java.home) and set the
  desktop jvmTarget to 21 (Android stays JVM 17 / minSdk 29). Fixes the startup
  UnsupportedClassVersionError and restores Markdown renderer 0.44.0.

Tooling/config:
- .pi-lens.json: disable verified-noisy heuristics (documented in docs).
- .gitleaks.toml: allowlist git-ignored false-positive paths.
- docs/18-code-review.md: full findings + verification.

Verified: ruff clean, pyright 0 errors, 64/64 gateway tests, all Kotlin tests,
Android lint 0 issues, Android installed+launched on device, desktop launches
on JDK 21.
This commit is contained in:
ARIA committed 2026-08-21 18:47:03 +02:00
1 parent 9f3f9842c8
commit 678c0344c8
27 files changed
+928 -454

No files matched your search

+9 -1
View File
@@ -27,6 +27,14 @@ android {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
// targetSdk is deliberately pinned to 34 (a stable API level): the
// reference device is API 29 and API 37 (the only newer installed
// platform) is a preview SDK, which is not appropriate to target for a
// stable build. Silence the informational OldTargetApi hint.
lint {
disable += "OldTargetApi"
}
}
kotlin {
@@ -41,7 +49,7 @@ dependencies {
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.ui:ui")
implementation("androidx.activity:activity-compose:1.13.0")
implementation("androidx.core:core-splashscreen:1.0.1")
implementation("androidx.core:core-splashscreen:1.2.0")
}
// M5: apply the google-services plugin only when a Firebase project is
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
@@ -3,4 +3,4 @@
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_monochrome" />
</adaptive-icon>
</adaptive-icon>
@@ -3,4 +3,4 @@
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_monochrome" />
</adaptive-icon>
</adaptive-icon>
+5
View File
@@ -1,4 +1,9 @@
org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8
# Desktop targets the Java 21 runtime (Markdown renderer 0.44.0 is
# Java-21 bytecode). AGP is JDK-21-compatible, so the Android build is
# unaffected (its bytecode target stays JVM 17 via minSdk/jvmTarget).
# Point this at your local JDK 21 if the path differs.
org.gradle.java.home=/usr/lib/jvm/java-21-openjdk
org.gradle.caching=true
org.gradle.configuration-cache=true
+8 -1
View File
@@ -36,7 +36,14 @@ kotlin {
}
withHostTest { }
}
jvm("desktop")
jvm("desktop") {
// Desktop runs on the Java 21 runtime (see gradle.properties
// org.gradle.java.home); target 21 so the Markdown renderer 0.44.0
// (Java-21 bytecode) loads. Android keeps its JVM 17 target above.
compilerOptions {
jvmTarget.set(JvmTarget.JVM_21)
}
}
sourceSets {
// Both targets are JVM-based (androidTarget + jvm("desktop")), so
@@ -43,6 +43,9 @@ fun ConnectScreen(
initialError: String? = null,
) {
val scope = rememberCoroutineScope()
// Default is a cleartext (non-TLS) URL because the typical gateway is on
// the LAN. A TLS gateway is reached by entering a secure (wss) URL instead.
// pi-lens-ignore: opengrep:javascript.lang.security.detect-insecure-websocket.detect-insecure-websocket
var url by remember { mutableStateOf(prefillUrl.ifBlank { "ws://" }) }
var token by remember { mutableStateOf(prefillToken) }
var busy by remember { mutableStateOf(false) }
@@ -76,6 +79,8 @@ fun ConnectScreen(
value = url,
onValueChange = { url = it },
label = { Text("Server URL") },
// Example LAN URL; wss:// works too for TLS gateways.
// pi-lens-ignore: opengrep:javascript.lang.security.detect-insecure-websocket.detect-insecure-websocket
placeholder = { Text("ws://192.168.1.10:8790/ws") },
singleLine = true,
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Uri),
@@ -12,7 +12,7 @@ expect fun localDayKey(epochMillis: Long): String
/** Current wall-clock time in epoch milliseconds (for locally generated items). */
expect fun nowMillis(): Long
/** Host part of a pairing URL ("ws://host:port/ws" -> "host:port"). */
/** Host part of a pairing URL (the "host:port" of the full gateway ws URL). */
fun hostFromUrl(url: String): String {
val noScheme = url.trim().substringAfter("://")
return noScheme.substringBefore("/").ifBlank { url.trim() }
@@ -306,8 +306,12 @@ private class SecretBackend(
private fun writeEncrypted(value: String) {
try {
// GCM with a fresh 12-byte SecureRandom IV per write (stored with
// the ciphertext); the IV is never reused for a given key.
// pi-lens-ignore: opengrep:kotlin.lang.security.gcm-detection.gcm-detection
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
val iv = ByteArray(12).also { SecureRandom().nextBytes(it) }
// pi-lens-ignore: opengrep:kotlin.lang.security.gcm-detection.gcm-detection
cipher.init(Cipher.ENCRYPT_MODE, SecretKeySpec(loadKey(), "AES"), GCMParameterSpec(128, iv))
val ct = cipher.doFinal(value.toByteArray(Charsets.UTF_8))
baseDir.mkdirs()
@@ -323,7 +327,9 @@ private class SecretBackend(
if (bytes.size < 28) return null
val iv = bytes.copyOfRange(0, 12)
val ct = bytes.copyOfRange(12, bytes.size)
// pi-lens-ignore: opengrep:kotlin.lang.security.gcm-detection.gcm-detection
val cipher = Cipher.getInstance("AES/GCM/NoPadding")
// pi-lens-ignore: opengrep:kotlin.lang.security.gcm-detection.gcm-detection
cipher.init(Cipher.DECRYPT_MODE, SecretKeySpec(loadKey(), "AES"), GCMParameterSpec(128, iv))
String(cipher.doFinal(ct), Charsets.UTF_8)
} catch (_: Exception) {