Skip to content

cleanup: remove private code nothing uses - #2417

Merged
ryanbr merged 1 commit into
ryanbr:mainfrom
UtkuDenizAltiok:cleanup-unused-private-code
Sep 23, 2026
Merged

ryanbr merged 1 commit into
ryanbr:mainfrom
UtkuDenizAltiok:cleanup-unused-private-code

Conversation

@UtkuDenizAltiok

Copy link
Copy Markdown

What this PR does

Removes 707 lines of private declarations that nothing reads, across 11 app files. Swift's private is file-scoped, so each was found by its name having no other use in its own file, and then removed; the macOS and iOS builds confirm none was still needed. Nothing a user can reach changes.

Most of it is Settings' WHOOP 5/MG research card, fiveMGCard, and what only that card used: the ECG raw-data gate readouts, the deep-data (R22) button state, the capture exports and their @AppStorage mirrors. #1709 (29 Aug) removed the card's only call site — if showFiveMGControls { fiveMGCard } — when the IMU capture sessions replaced it, and the body stayed behind. The UserDefaults keys and the features behind them are untouched; only unreachable UI code goes.

The rest are small leftovers: RawHistoryArchive.versionKey, BiofeedbackController.scheduleBuzz, SettingsView.temperatureUnit, FullDayChartView.reloadTick, SleepView.dayParser, LiveWorkoutView.workoutTypeGlassButton (a placeholder button) and activeSportName, Today's scoringGuideFirstRunCard, synthesisCardColor, dateLine, synthesisTitle and ringSupporting, LiveView.liquidHeart, IntervalTimerView.phaseTone, TrendsView.latestDay and WeeklyDigestContent.order.

Kept on purpose, although nothing reads them by name: @UIApplicationDelegateAdaptor appDelegate and DomainTheme's @Environment(\.colorScheme), which make SwiftUI do something (host the delegate, re-render on a change). LiftLogView.unitSystem is unused too, but it sits on an @AppStorage whose re-render may matter to the hub's rows; that was not settled here, so the file is untouched.

Strings that only these views used stay in Localizable.xcstrings; the catalog's own stale-key handling can take them, and a hand edit of the 6 MB file is riskier than the leftover keys.

Type of change

  • Refactor / cleanup

How it was tested

  • The scan: every private/fileprivate func/var/let in the app targets and Packages/*/Sources (5,751 declarations), counted by name within its file with comments stripped; repeated after each removal until nothing new fell out.
  • Full local run on the change (187b264d, on 266a8702; the head 87f03749 is the same diff rebased): WhoopStore 611 · StrandAnalytics 2048 · StrandImport 327 · doc lint · i18n · macOS StrandTests 2,107 (the only failures are the two locale-dependent TodayCarryOverTests, which fail on clean main too) · iOS build. Rebased onto 5783c499; none of the newer commits touches these 11 files.
  • The parity ledger, ratchet and governance tests fail locally, and fail identically on a clean checkout of main (twin-map authority drift; the scheduled Parity Governance run failed on 971d0d9f). Nothing here is under Packages/** or android/**.

Checklist

  • No UI change a user can reach; no StrandDesign tokens involved
  • Follows the conventions in docs/CONTRIBUTING.md
  • I did not commit generated output (Strand.xcodeproj/) or any secrets/keystores

Related issues

Refs #1709 (removed the research card's call site)

🤖 Generated with Claude Code

707 lines of private declarations with no reader left, across 11 files. Swift's private is file-scoped,
so each was checked by name within its own file, and the compiler confirms none was still needed.

Most of it is Settings' WHOOP 5/MG research card (fiveMGCard) and what only it used: the ECG raw-data
gate readouts, the deep-data (R22) button state, the capture exports and their @AppStorage mirrors.
ryanbr#1709 removed the card's only call site (`if showFiveMGControls { fiveMGCard }`) on 29 Aug when the
IMU capture sessions replaced it, and left the body behind. Their UserDefaults keys and the features
behind them are untouched; only unreachable UI code goes.

The rest are small leftovers: helpers, a formatter, a colour, a placeholder button and a first-run card
on Today that nothing renders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ryanbr ryanbr left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @UtkuDenizAltiok. The method is the right one for this: private is file-scoped, so "no other use in its own file" plus a compile really is close to proof, and scanning all 5,751 declarations and re-running after each removal is how you avoid the cascade being missed.

I went after the one hole that method has, which is a use the built configuration never sees. It does not bite here, and it is worth writing down why:

  • The only conditions in these 11 files are os(iOS) (46), os(macOS) (21), DEBUG (16) and canImport(UIKit) (2). The iOS leg compiles the first and the fourth, the macOS leg the second, and both legs build -configuration Debug, so every #if DEBUG body is compiled too.
  • The #else branches matter more than the #if ones, because an #else on #if DEBUG is release-only and NO leg builds it. There are exactly three, all in TodayView.swift (at 1449, 2985, 3048), and none of them names a removed symbol.
  • Nothing here is under #if os(watchOS), so the watch target not being in the build matrix costs nothing.

I also checked every one of the 31 removed declarations for a surviving reference in the file it came from, since that is the scope that decides it. Two came back, and both are documentation rather than code.

Two comments now point at nothing

Strand/Screens/SettingsView.swift:1936  /// … split out of `fiveMGCard` (2026-08-23): the toggle's
Strand/Screens/SettingsView.swift:2019  /// … the same pattern as exportPuffinCaptures().

Neither breaks the build, which is why the compile is happy, but this codebase leans on comments that name their neighbours, and both now send a reader looking for something that is not there. The 1936 one can say the card was removed in #1709 and this cleanup took the body; the 2019 one needs a different exemplar for the save-panel and share-sheet pattern, since the one it cites is gone.

Smaller

The branch is one commit behind now, which is #2377 landing in LiquidTodayView.swift. It does not touch your 11 files, so this merges clean and I am not asking for a rebase on its account.

Keeping appDelegate and DomainTheme's colorScheme, and leaving LiftLogView.unitSystem alone rather than guessing about its re-render, is the right instinct: an unread property that makes SwiftUI do something is not dead code, and the honest answer to an unsettled one is to leave it.

Fix the two comments and this is ready.

@ryanbr
ryanbr merged commit be060c2 into ryanbr:main Sep 23, 2026
4 checks passed
ryanbr added a commit that referenced this pull request Sep 23, 2026
#2417 removed 707 lines of unreachable private code. Three comments named
symbols that went with it, so a reader chasing them found nothing.

  SettingsView.swift  the SpO2 card's provenance cited `fiveMGCard`
  SettingsView.swift  the raw-sensor CSV export cited exportPuffinCaptures()
  BLEManager.swift    the ECG bond gate cited the button's `ecgGateReady`

Each keeps its history and says where the referent went, rather than dropping
the sentence: the provenance of the SpO2 split and the reason the ECG write
needs the full encrypted bond are both worth more than the dead name was.

The BLEManager one is the interesting miss. Reviewing #2417 I checked every
removed declaration for a surviving reference in the file it came from, which
is the scope that decides whether a private symbol can still be referenced in
CODE. A comment has no such scope, and that one sat in a different file.
Backticked identifiers are the convention here, so the sweep that finds these
is for a backticked name in a comment in a file that no longer declares it.
UtkuDenizAltiok added a commit to UtkuDenizAltiok/noop that referenced this pull request Sep 23, 2026
@UtkuDenizAltiok
UtkuDenizAltiok deleted the cleanup-unused-private-code branch September 23, 2026 11:41
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.

2 participants