Skip to content

Compiler-warning cleanup: redundant operators, AutoMirrored icons, shadows, always-true conditions - #6

Merged
ryanbr merged 4 commits into
mainfrom
snapshot-v8.2.2
Jul 7, 2026
Merged

ryanbr merged 4 commits into
mainfrom
snapshot-v8.2.2

Conversation

@ryanbr

@ryanbr ryanbr commented Jul 7, 2026

Copy link
Copy Markdown
Owner

What

Compiler-warning cleanup — all non-behavioral, each commit compile-verified (compileFullDebugKotlin BUILD SUCCESSFUL; ingest+data unit tests pass on the structural ones).

  • d932b25a — redundant operators: unnecessary safe-calls / !! / as Double? casts (AiCoach, CaffeineDecay, WatchRecovery).
  • 5c617dbf — deprecated Material icons → AutoMirrored (BreatheScreen, CoachScreen, DashboardCards, HealthScreen, LabBookScreen); unnecessary safe-calls (SourceCoordinator, HealthScreen); redundant Elvis (HrvSnapshotScreen); exhaustive-when else (DataBackup); redundant initializer (CsvParser); name-shadow renames (Backfiller, StandardHrSource).
  • 5003222e — more AutoMirrored icons (NotificationsSettingsScreen, SettingsScreen, StepsCalibrationScreen, TodayScreen); 5 compiler-proven always-true null sub-conditions removed + shadow rename + dead lambda (TodayScreen); shadow rename (SleepScreen); dead assignment (TrendsReport).
  • 9c52ecbf — UpdateStore null-fallback type mismatches (optString(name, null) → guarded idiom); WorkoutsScreen AutoMirrored icons.

Deliberately not touched

The "unused parameter" warnings (e.g. inBedSeconds, nightsElapsed, habitualWakeHour, day, resp, data, batch, g, color, TodayScreen composable params) are left as-is — they're Kotlin↔Swift signature-parity mirrors or composable-signature params, so removing them would break parity / churn callers. Accepted as benign noise (policy A).

No behavior changes; UI icons only gain automatic RTL mirroring.

ryanbr added 4 commits July 7, 2026 14:34
- AiCoach.parseReply: firstChoice is smart-cast non-null after the content guard, so the
  finish_reason safe calls were redundant -> plain calls (optString returns non-null).
- CaffeineDecay: `mostRecentActiveHours!!` is redundant inside `x == null || … x` (smart-cast).
- WatchRecovery: `hrvHistory/rhrHistory.map { it as Double? }` -> pass List<Double> straight to
  foldHistory(List<Double?>) via List covariance; the casts (and identity map) were unnecessary.

Left as-is: the "unused parameter" warnings on inBedSeconds / nightsElapsed / habitualWakeHour /
day / resp are deliberate Kotlin<->Swift signature-parity mirrors (each exists in the Swift twin),
so removing them would break parity. compileFullDebugKotlin: BUILD SUCCESSFUL, those 4 gone.
…adows

All non-behavioural (compile-verified, ingest+data tests 298 pass):
- Deprecated Material icons → AutoMirrored variants (import + usage): VolumeUp/VolumeOff/
  ArrowForward (BreatheScreen), Send (CoachScreen), DirectionsWalk/DirectionsRun (DashboardCards),
  MenuBook (HealthScreen, LabBookScreen).
- Unnecessary safe calls on smart-cast-non-null receivers: SourceCoordinator (row.model),
  HealthScreen (day.recovery).
- HrvSnapshotScreen: dropped a redundant Elvis (r.rmssd is non-null here).
- DataBackup: removed the redundant `else` on an exhaustive `when`.
- CsvParser: dropped the redundant `= 0` initializer on `hours` (assigned on every branch).
- Name-shadow renames: Backfiller `unix`→`recUnix`, StandardHrSource inner `ch`→`sensorCh`.

Left as-is: the remaining "unused parameter" warnings — `data` (WearableExportImporter) is a
Swift-parity mirror (isWellnessFile(..., data:) exists in Swift); `batch`/`g` (WhoopBleClient) are
Android GATT-helper signature params; `color` (CoachMarkdown.parseInline) is passed by all callers.
All non-behavioural (compile-verified):
- Deprecated icons → AutoMirrored: Chat + OpenInNew (NotificationsSettingsScreen),
  MenuBook (SettingsScreen), DirectionsWalk (StepsCalibrationScreen), BatteryUnknown (TodayScreen).
- TodayScreen: removed 5 compiler-proven always-true null sub-conditions (recovery/strain/sleep
  are non-null there), renamed a shadowed inner `live`→`liveStrain`, deleted an unused
  `dismissScoringCard` lambda (never referenced).
- SleepScreen: renamed shadowed inner `imported`→`importedSessions`.
- TrendsReport: dropped a dead assignment (`y = drawMetrics(...)` → `drawMetrics(...)`; y unused after).

Left as-is: the "unused parameter" warnings (TodayScreen composable params, TestCentre `vm`,
TimeOfDayBackground `w`) — composable/Swift-parity signature params; removing risks parity + churn.
…cons

- UpdateStore.fromJson: `o.optString(name, null)` passes null where Android's optString(name, String)
  wants a non-null fallback (Nothing?-vs-String warning). Use the `if (o.has(name)) o.optString(name)
  else null` idiom — same result (value or null), no warning. deepLink/restorePayload already had the
  o.has guard so the inner `, null` was dead; kind gains the guard too.
- WorkoutsScreen: deprecated icons → AutoMirrored (ShowChart, MergeType, DirectionsRun x2,
  DirectionsWalk, DirectionsBike).

Non-behavioural; compileFullDebugKotlin BUILD SUCCESSFUL.
@ryanbr
ryanbr merged commit 2569c25 into main Jul 7, 2026
DX23876 referenced this pull request in DX23876/noop Jul 22, 2026
Compiler-warning cleanup: redundant operators, AutoMirrored icons, shadows, always-true conditions
xxblyxx added a commit to xxblyxx/noop that referenced this pull request Sep 1, 2026
… dropping

The re-score storm reduction commits on this branch never got the
15-minute minimum interval between automatic passes the original plan
specified for Commit 1 (deferred openly in 59771a0's message, never
followed up). A device log pulled 2026-08-25 showed the cost: 5 passes /
~7.9 min re-score CPU in a 44-minute window, versus a <=2 passes / <2 min
target, because nothing capped how often an automatic tick or post-offload
pass could re-run the same window.

New Strand/Data/AnalyzePolicy.swift, shaped like the existing
Strand/BLE/BackfillPolicy.swift: a pure enum, an AnalyzeTrigger naming
what asked, and a decide() function returning .run or .deferUntil(instant)
- deferred, not dropped, since an automatic re-score guards a
freshly-synced night's data reaching the dashboard. 900s floor, matching
BackfillPolicy.periodicFloorSeconds. .dataChange (every user- or
data-driven caller: manual re-score, import, edit, recalibrate, heals) and
.background (the BGProcessingTask wake, whose own fingerprint gate is
trustworthy while the process is suspended) always bypass. A local-midnight
rollover, using the exact AnalyticsEngine.dayString helper analyzeRecent's
own scoring loop uses, also always runs, so the first pass after midnight
is never floored.

IntelligenceEngine.analyzeRecent gains a trigger: AnalyzeTrigger =
.dataChange parameter (the default bypasses the floor for every existing
caller) and checks the floor FIRST - before the ryanbr#899-A lock guard and
before any store read, so a floored trigger costs nothing and never sets
pendingForcedRescore. deferredRescoreDueAt publishes the rejected instant.
The floor's own watermark (noop.analyze.lastPassEndedAt) is written at
completion gated on !Task.isCancelled ONLY, never combined with the
stricter !wmKey.isEmpty check the watermark write beside it uses - the
same class of bug review finding ryanbr#6 already fixed once for
completedPassCount, now avoided here by construction.

AppModel wires the post-offload caller (refreshAfterCompletedBackfill) and
the 30-minute cadence tick to the floor, and adds a coalesced single-retry
Task via a new $deferredRescoreDueAt sink in init() so a floored trigger is
never silently lost - it retries once, through
refreshAfterCompletedBackfill (inheriting its reentrancy guard and bar
teardown), at the deferred instant. The post-offload floor check sits
AFTER repo.refresh(days: 120), not before, so a floored pass still
surfaces newly-offloaded raw to Trends/streak reads - skipping that would
reproduce the ryanbr#1196 flicker shape; only the analyze pass and progress bar
are skipped.

New StrandTests/AnalyzePolicyTests.swift pins the floor boundary (elapsed
>= 900 vs <), the .dataChange/.background bypass, backwards-clock
self-healing, and the local-midnight rollover at a non-zero tzOffsetSec.

Second of five commits implementing
docs/superpowers/plans/2026-08-25-rescore-floor.md. No Kotlin twin: pure
iOS scheduling, and Android's analyzeGate is a Mutex with different
semantics (blocks-then-runs, not drop-and-rearm) - 066d562 already
reverted one attempt to mechanically mirror a Swift scheduling constant
into that model. Kotlin cannot be compiled on this machine; nothing was run
against it.

Verified: full iOS build (xcodegen generate && xcodebuild -scheme NOOPiOS
-destination 'generic/platform=iOS' CODE_SIGNING_ALLOWED=NO build) and the
macOS test suite (xcodebuild -scheme Strand -destination 'platform=macOS'
test, 1221 tests / 0 failures, including all 6 new AnalyzePolicyTests)
both pass against the full branch state (this commit plus the two that
follow it).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XeGMt5M6bknba8Zm8WFe6L
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant