cleanup: remove private code nothing uses - #2417
Conversation
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
left a comment
There was a problem hiding this comment.
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) andcanImport(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 DEBUGbody is compiled too. - The
#elsebranches matter more than the#ifones, because an#elseon#if DEBUGis release-only and NO leg builds it. There are exactly three, all inTodayView.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.
#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.
…2417 ryanbr#2418 opened; build 6adaf45
What this PR does
Removes 707 lines of
privatedeclarations that nothing reads, across 11 app files. Swift'sprivateis 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@AppStoragemirrors. #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) andactiveSportName, Today'sscoringGuideFirstRunCard,synthesisCardColor,dateLine,synthesisTitleandringSupporting,LiveView.liquidHeart,IntervalTimerView.phaseTone,TrendsView.latestDayandWeeklyDigestContent.order.Kept on purpose, although nothing reads them by name:
@UIApplicationDelegateAdaptor appDelegateandDomainTheme's@Environment(\.colorScheme), which make SwiftUI do something (host the delegate, re-render on a change).LiftLogView.unitSystemis unused too, but it sits on an@AppStoragewhose 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
How it was tested
private/fileprivatefunc/var/letin the app targets andPackages/*/Sources(5,751 declarations), counted by name within its file with comments stripped; repeated after each removal until nothing new fell out.187b264d, on266a8702; the head87f03749is the same diff rebased): WhoopStore 611 · StrandAnalytics 2048 · StrandImport 327 · doc lint · i18n · macOSStrandTests2,107 (the only failures are the two locale-dependentTodayCarryOverTests, which fail on cleanmaintoo) · iOS build. Rebased onto5783c499; none of the newer commits touches these 11 files.main(twin-map authority drift; the scheduled Parity Governance run failed on971d0d9f). Nothing here is underPackages/**orandroid/**.Checklist
docs/CONTRIBUTING.mdStrand.xcodeproj/) or any secrets/keystoresRelated issues
Refs #1709 (removed the research card's call site)
🤖 Generated with Claude Code