Skip to content

chore: retire bounded code-health debt - #46

Merged
sarthakagrawal927 merged 2 commits into
mainfrom
fix/reduce-code-health-debt-38
Aug 15, 2026
Merged

chore: retire bounded code-health debt#46
sarthakagrawal927 merged 2 commits into
mainfrom
fix/reduce-code-health-debt-38

Conversation

@sarthakagrawal927

Copy link
Copy Markdown
Member

Summary

Retires bounded code-health debt after baseline adoption (#38). Three behavior-preserving refactors lower the checked-in ratchets without changing product behavior, catalog/playback behavior, or D1 data.

Changes

1. Split applyPreference in src/lib/smartmix.ts (CCN 18 → 6)

Extracted an adjustWeight helper and replaced mirrored if/else blocks with ternary branches. The favorite/dislike paths now share a single weight-adjustment loop instead of duplicating the logic. All 232 tests pass, including the Smart Mix performance regression test with its pinned SHA-256 hashes.

2. Extract toggleWatchLaterId in src/components/TVApp.tsx

The onToggleWatchLater callback was duplicated across two <Search> instances and the <ControlRail>. Extracted a module-level toggleWatchLaterId function (outside the component body) so all three callsites share one implementation. This shrank the largest duplication clone from 24 to 12 lines.

3. Extract FeaturesSection component (src/components/FeaturesSection.tsx)

The "Why LoopTV" features grid was duplicated verbatim in AboutPage.tsx and LandingPage.tsx. Extracted a shared presentational component that accepts features and className props, eliminating the 16-line clone entirely.

Baseline improvements

Metric Before After
Complexity violations 21 20
Duplication clone groups 4 3
Duplication duplicated lines 62 35

Baselines lowered in scripts/check-code-health.mjs — only lowered, never raised.

Verification

pnpm quality  # full CI gate: format, lint, typecheck, test:coverage, all health checks, docs, build, hygiene

All 232 tests pass. Full quality gate passes green.

Progress on #38

Split applyPreference (CCN 18→6) by extracting adjustWeight helper and
using ternary branches instead of mirrored if/else blocks.

Extract toggleWatchLaterId module-level function in TVApp.tsx to
deduplicate the onToggleWatchLater callback repeated across two Search
instances and the ControlRail.

Extract FeaturesSection component shared by AboutPage and LandingPage
to eliminate the duplicated features grid markup.

Lower baselines in check-code-health.mjs:
- complexity violations: 21 → 20
- duplication clones: 4 → 3
- duplication duplicatedLines: 62 → 35

Progress on #38
@github-actions

Copy link
Copy Markdown
Contributor

Preview: https://pr-46.looptv.pages.dev

Add page_view as the 5th event alongside signup, activated, core_action,
and returned. Wire trackPageView() into the PostHog provider on mount
and route changes.

Part of fleet-workspace#348

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Preview: https://pr-46.looptv.pages.dev

@sarthakagrawal927
sarthakagrawal927 merged commit 9214971 into main Aug 15, 2026
3 checks passed
@sarthakagrawal927
sarthakagrawal927 deleted the fix/reduce-code-health-debt-38 branch August 15, 2026 20:28
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