Skip to content

chore(detekt): scan flavor, iosMain and jvmAndroidMain sources - #6836

Merged
jamesarich merged 3 commits into
mainfrom
chore/detekt-flavor-sources
Aug 23, 2026
Merged

chore(detekt): scan flavor, iosMain and jvmAndroidMain sources#6836
jamesarich merged 3 commits into
mainfrom
chore/detekt-flavor-sources

Conversation

@jamesarich

@jamesarich jamesarich commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

detekt's source list in the convention plugin only named src/main, src/commonMain, src/androidMain, and src/jvmMain — so despite the zero-lint gate, four production source sets were never analyzed at all:

Source set Files never scanned
src/fdroid + src/google 75 (androidApp, core:barcode)
src/iosMain 29 (12 KMP modules)
src/jvmAndroidMain 14

Turning them on surfaced ~150 accumulated violations. This PR fixes the mechanical ones and baselines the structural rest, per the existing per-module-baseline convention (Detekt.kt's own comment: remove baselines incrementally as modules are cleaned up). Test source sets remain unscanned, matching the original list's policy.

(Found while working on #6834 — an adversarial review of that branch noticed its new fdroid-flavor code was never being linted.)

🧹 Chores

  • Detekt.kt: list every production source set that ships code, with a comment explaining why explicitness matters here.
  • Fixed (~66 violations, no behavior change):
    • MagicNumber (~45): named constants across both flavors' map/AI code and core:takserver, reusing canonical values where they exist (Marker.ANCHOR_CENTER, GeoConstants.DEG_D/HEADING_DEG).
    • ParameterNaming (3 renames): onPositionSelect, onMappableCountChange, onManageCustomTileProvidersClick — kept identical across the fdroid/google flavor pairs, all named-argument call sites updated (incl. MainActivity).
    • FunctionOnlyReturningConstant (4): suppressed with rationale — flavor-dispatch functions whose counterpart returns a different constant, so the function-ness is load-bearing.
    • UnusedParameter in MeshtasticAppFunctions: class-level suppress — the androidx AppFunctions calling convention requires the AppFunctionContext parameter.
    • EmptyFunctionBlock (3) in iOS no-op stubs, one MaxLineLength wrap.
  • Baselined (structural refactors, not drive-by material): androidApp's 58 remaining flavor findings (LongMethod, complexity, ViewModelForwarding, TooGenericExceptionCaught, ThrowsCount, …) plus small counts in core:ui, core:takserver, feature:settings. The ParameterNaming hits on iosMain actual functions stay baselined deliberately: renaming an actual's parameters desyncs the commonMain expect declaration, and renaming both sides is a public-API refactor. core:testing's baseline held exactly one now-fixed entry, so it's deleted.

Testing Performed

  • ./gradlew spotlessApply spotlessCheck detekt assembleDebug test allTests kmpSmokeCompile — fully green (kmpSmokeCompile included because iosMain files changed and must still compile for the iOS targets).
  • From here on, any new violation in the 118 newly covered files fails the build like everywhere else.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor

    • Standardized map-related callback names and configuration labels.
    • Replaced scattered numeric values with descriptive shared constants, preserving existing map, routing, and visualization behavior.
    • Clarified platform-specific no-op implementations and service availability handling.
  • Chores

    • Expanded static-analysis coverage and updated baselines across Android, iOS, and shared modules.
    • Improved inline documentation and lint-warning handling.
    • No functional changes or visible interface changes are expected.

jamesarich and others added 2 commits August 23, 2026 17:23
detekt's source list only named the main/common source sets, so
src/fdroid, src/google (75 files in androidApp and core:barcode),
src/iosMain (29 files), and src/jvmAndroidMain (14 files) were never
analyzed despite the zero-lint gate. List every production source set
that ships code; test source sets stay unscanned, matching the
original list's policy.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The subset of the 139 surfaced violations that can be fixed without
behavior change:

- MagicNumber: extracted named constants across the fdroid and google
  map/AI files, reusing canonical values where they exist
  (Marker.ANCHOR_CENTER, GeoConstants.DEG_D/HEADING_DEG).
- ParameterNaming: lambda parameters to present tense
  (onPositionSelect, onMappableCountChange,
  onManageCustomTileProvidersClick), kept identical across the
  flavor pairs, all named-argument call sites updated.
- FunctionOnlyReturningConstant: suppressed with rationale — these
  are flavor-dispatch functions whose counterpart returns a
  different constant, so the function-ness is load-bearing.
- UnusedParameter in MeshtasticAppFunctions: suppressed at class
  level — the androidx AppFunctions calling convention requires the
  AppFunctionContext parameter.
- EmptyFunctionBlock/MaxLineLength: no-op comment and line wrap.

Structural findings (LongMethod, complexity, ViewModelForwarding,
TooGenericExceptionCaught, ThrowsCount, ...) are left to the
per-module baseline, per the existing incremental-cleanup convention.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4c755396-83bf-456f-a043-c551a462d057

📥 Commits

Reviewing files that changed from the base of the PR and between 0daac75 and 634141b.

📒 Files selected for processing (34)
  • androidApp/detekt-baseline.xml
  • androidApp/src/fdroid/kotlin/org/meshtastic/app/di/FlavorModule.kt
  • androidApp/src/fdroid/kotlin/org/meshtastic/app/map/FdroidMapOverlayRenderer.kt
  • androidApp/src/fdroid/kotlin/org/meshtastic/app/map/GetMapViewProvider.kt
  • androidApp/src/fdroid/kotlin/org/meshtastic/app/map/MapView.kt
  • androidApp/src/fdroid/kotlin/org/meshtastic/app/map/MapViewExtensions.kt
  • androidApp/src/fdroid/kotlin/org/meshtastic/app/map/component/DownloadButton.kt
  • androidApp/src/fdroid/kotlin/org/meshtastic/app/map/model/MarkerWithLabel.kt
  • androidApp/src/fdroid/kotlin/org/meshtastic/app/map/model/NOAAWmsTileSource.kt
  • androidApp/src/fdroid/kotlin/org/meshtastic/app/map/node/NodeTrackMap.kt
  • androidApp/src/fdroid/kotlin/org/meshtastic/app/map/node/NodeTrackOsmMap.kt
  • androidApp/src/fdroid/kotlin/org/meshtastic/app/map/traceroute/TracerouteMap.kt
  • androidApp/src/fdroid/kotlin/org/meshtastic/app/map/traceroute/TracerouteOsmMap.kt
  • androidApp/src/fdroid/kotlin/org/meshtastic/app/node/component/InlineMap.kt
  • androidApp/src/google/kotlin/org/meshtastic/app/ai/GeminiNanoDocAssistant.kt
  • androidApp/src/google/kotlin/org/meshtastic/app/ai/appfunctions/MeshtasticAppFunctions.kt
  • androidApp/src/google/kotlin/org/meshtastic/app/di/AppFunctionsModule.kt
  • androidApp/src/google/kotlin/org/meshtastic/app/map/GetMapViewProvider.kt
  • androidApp/src/google/kotlin/org/meshtastic/app/map/MBTilesProvider.kt
  • androidApp/src/google/kotlin/org/meshtastic/app/map/MapView.kt
  • androidApp/src/google/kotlin/org/meshtastic/app/map/MapViewModel.kt
  • androidApp/src/google/kotlin/org/meshtastic/app/map/component/MapTypeDropdown.kt
  • androidApp/src/google/kotlin/org/meshtastic/app/map/component/PulsingNodeChip.kt
  • androidApp/src/google/kotlin/org/meshtastic/app/map/model/CustomTileSource.kt
  • androidApp/src/google/kotlin/org/meshtastic/app/map/node/NodeTrackMap.kt
  • androidApp/src/google/kotlin/org/meshtastic/app/map/traceroute/TracerouteMap.kt
  • androidApp/src/main/kotlin/org/meshtastic/app/MainActivity.kt
  • build-logic/convention/src/main/kotlin/org/meshtastic/buildlogic/Detekt.kt
  • core/takserver/detekt-baseline.xml
  • core/takserver/src/jvmAndroidMain/kotlin/org/meshtastic/core/takserver/TAKServerJvm.kt
  • core/testing/src/iosMain/kotlin/org/meshtastic/core/testing/TestUtils.ios.kt
  • core/ui/detekt-baseline.xml
  • core/ui/src/iosMain/kotlin/org/meshtastic/core/ui/util/NoopStubs.kt
  • feature/settings/detekt-baseline.xml

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The pull request updates Detekt source coverage and baselines, replaces map literals with named constants, renames map callback parameters, and documents flavor-specific and iOS no-op implementations.

Changes

Static analysis and map maintenance

Layer / File(s) Summary
Detekt source coverage and baselines
build-logic/convention/..., androidApp/detekt-baseline.xml, core/takserver/detekt-baseline.xml, core/ui/detekt-baseline.xml, feature/settings/detekt-baseline.xml
Detekt now scans additional production source sets. Module baselines add, remove, and reorder issue suppressions.
Map constants and equivalent calculations
androidApp/src/fdroid/kotlin/org/meshtastic/app/map/..., androidApp/src/google/kotlin/org/meshtastic/app/map/...
Map rendering, tile, waypoint, download, and pulsing code uses named constants for existing numeric values.
Map callback naming and wiring
androidApp/src/fdroid/kotlin/org/meshtastic/app/map/node/..., androidApp/src/fdroid/kotlin/org/meshtastic/app/map/traceroute/..., androidApp/src/google/kotlin/org/meshtastic/app/map/..., androidApp/src/main/kotlin/...
Node selection, traceroute count, and custom tile provider callback parameters are renamed and forwarded through callers.
Flavor, AI, and platform lint adjustments
androidApp/src/..., core/takserver/src/..., core/testing/src/..., core/ui/src/...
Flavor-specific suppressions, AI assistant constants, socket configuration naming, and documented iOS no-op stubs are updated.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 63414

The change expands production-source lint coverage, applies mechanical cleanup, and records existing structural findings in module baselines without reported behavior changes; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 8
✅ Passed checks (8 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: expanding Detekt scanning to flavor, iOS, and JVM Android production sources.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Sibling Call Sites And Presence Semantics ✅ Passed The PR does not change metric presence semantics. NodeItem and NodeItemCompact are unchanged; CompactMetricsRow already uses nullable temperature, and no physical metric field defaults to 0 was added.
Tests Prove The Path, Not The End State ✅ Passed The complete PR diff adds or changes no test files or assertions; the only test utility change keeps setupTestContext as an empty iOS no-op.
Regression Coverage For Changed Behavior ✅ Passed Diff review found no non-trivial runtime behavior change: value substitutions preserve constants, callbacks are mechanical renames, and iOS stubs remain no-ops; no regression test gap applies.
Moved Code Diffed Against Its Original ✅ Passed The PR adds no source files and deletes no types or functions; all Kotlin edits are in-place constants, suppressions, renames, or no-op formatting, with no moved-code behavior change.

Warning

Some tools did not complete. Review the errors below.

🔧 PMD (7.26.0)
androidApp/src/main/kotlin/org/meshtastic/app/MainActivity.kt

Picked up JAVA_TOOL_OPTIONS: -XX:+PerfDisableSharedMem
openjdk version "17.0.20" 2026-07-21 LTS
OpenJDK Runtime Environment Corretto-17.0.20.8.1 (build 17.0.20+8-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.20.8.1 (build 17.0.20+8-LTS, mixed mode, sharing)
Picked up JAVA_TOOL_OPTIONS: -XX:+PerfDisableSharedMem
[0.170s][warning][os,thread] Failed to start thread "Unknown thread" - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 0k, detached.
Error occurred during initialization of VM
java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached

androidApp/src/fdroid/kotlin/org/meshtastic/app/map/FdroidMapOverlayRenderer.kt

Picked up JAVA_TOOL_OPTIONS: -XX:+PerfDisableSharedMem
openjdk version "17.0.20" 2026-07-21 LTS
OpenJDK Runtime Environment Corretto-17.0.20.8.1 (build 17.0.20+8-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.20.8.1 (build 17.0.20+8-LTS, mixed mode, sharing)
Picked up JAVA_TOOL_OPTIONS: -XX:+PerfDisableSharedMem
[0.223s][warning][os,thread] Failed to start thread "Unknown thread" - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 0k, detached.
Error occurred during initialization of VM
java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached

androidApp/src/google/kotlin/org/meshtastic/app/map/GetMapViewProvider.kt

Picked up JAVA_TOOL_OPTIONS: -XX:+PerfDisableSharedMem
openjdk version "17.0.20" 2026-07-21 LTS
OpenJDK Runtime Environment Corretto-17.0.20.8.1 (build 17.0.20+8-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.20.8.1 (build 17.0.20+8-LTS, mixed mode, sharing)
Picked up JAVA_TOOL_OPTIONS: -XX:+PerfDisableSharedMem
[0.335s][warning][os,thread] Failed to start thread "Unknown thread" - pthread_create failed (EAGAIN) for attributes: stacksize: 1024k, guardsize: 0k, detached.
[0.336s][warning][os,thread] Failed to start the native thread for java.lang.Thread "Common-Cleaner"
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
at java.base/java.lang.Thread.start0(Native Method)
at java.base/java.lang.Thread.start(Thread.java:809)
at java.base/jdk.internal.ref.CleanerImpl.start(CleanerImpl.java:112)
at java.base/java.lang.re

... [truncated 1316 characters] ...

.internal.loader.URLClassPath.getResource(URLClassPath.java:320)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:757)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:469)
at java.base/sun.launcher.LauncherHelper.loadMainClass(LauncherHelper.java:811)
at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:706)

  • 12 others

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added build Build system changes chore labels Aug 23, 2026
Regenerated per-module baselines for the violations left after the
mechanical pass — androidApp's flavor code (58 structural findings:
LongMethod, complexity, ViewModelForwarding, TooGenericExceptionCaught,
...) plus core:ui and feature:settings iosMain entries. The
ParameterNaming findings on iosMain actual functions stay baselined
deliberately: renaming an actual's parameters desyncs the commonMain
expect declaration, and renaming both sides is a public-API refactor.

Fixed the ones that needed no such trade-off:
- EmptyFunctionBlock in TestUtils.ios.kt and NoopStubs.kt no-op stubs
- MagicNumber in TAKServerJvm (SERVER_SOCKET_BACKLOG)

core:testing's baseline held only the now-fixed entry, so it is gone
again.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jamesarich
jamesarich force-pushed the chore/detekt-flavor-sources branch from 96789e5 to 634141b Compare August 23, 2026 22:53
@jamesarich
jamesarich marked this pull request as ready for review August 23, 2026 23:20
@jamesarich
jamesarich added this pull request to the merge queue Aug 23, 2026
Merged via the queue into main with commit 60002de Aug 23, 2026
15 checks passed
@jamesarich
jamesarich deleted the chore/detekt-flavor-sources branch August 23, 2026 23:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Build system changes chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant