chore: retire bounded code-health debt - #46
Merged
Conversation
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
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>
Contributor
|
Preview: https://pr-46.looptv.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
applyPreferenceinsrc/lib/smartmix.ts(CCN 18 → 6)Extracted an
adjustWeighthelper 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
toggleWatchLaterIdinsrc/components/TVApp.tsxThe
onToggleWatchLatercallback was duplicated across two<Search>instances and the<ControlRail>. Extracted a module-leveltoggleWatchLaterIdfunction (outside the component body) so all three callsites share one implementation. This shrank the largest duplication clone from 24 to 12 lines.3. Extract
FeaturesSectioncomponent (src/components/FeaturesSection.tsx)The "Why LoopTV" features grid was duplicated verbatim in
AboutPage.tsxandLandingPage.tsx. Extracted a shared presentational component that acceptsfeaturesandclassNameprops, eliminating the 16-line clone entirely.Baseline improvements
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, hygieneAll 232 tests pass. Full quality gate passes green.
Progress on #38