chore: reduce accepted code-health debt - #57
Merged
Conversation
Reduce complexity violations (81→72) and duplication (47→43 clones, 750→716 lines, 2.145%→2.044%) through behavior-preserving refactors: - extension/src/content.ts: extract textFromSelectors helper and firstScraperResult to eliminate ?? chains in scraper functions (scrapePersonio, scrapeWorkable, scrapeLinkedIn, scrapeSmartRecruiters, scrape — 5 violations removed) - src/lib/local-storage.ts: extract optionalJobFields helper shared by toJobApplication and toSummary (2 violations removed) - src/lib/evidence-mapping.ts: consolidate toEvidence/toPacketEvidence/ toReplyEvidence into shared rowToEvidence utility, eliminating triplicated row-mapping code (3 violations removed, 4 clone groups eliminated) Lower checked-in baselines in scripts/check-code-health.mjs to reflect the improvements. Progress on #50
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
Reduce accepted code-health debt for #50 through behavior-preserving refactors. All 439 tests pass, typecheck clean, full quality gate green.
Changes
Complexity: 81 → 72 violations (−9)
extension/src/content.ts — 5 violations removed:
textFromSelectors(...selectors)helper to replace??-chains oftextFromSelectorcalls in all scraper functions (scrapePersonio,scrapeWorkable,scrapeLinkedIn,scrapeSmartRecruiters,scrapeGeneric)firstScraperResult()to replace the 10-way??chain inscrape()src/lib/local-storage.ts — 2 violations removed:
optionalJobFields(j)helper shared bytoJobApplication(CCN 29→5) and3), splitting thetoSummary(CCN 21→??chains across two smaller functionssrc/lib/evidence-mapping.ts (new) — 3 violations removed:
toEvidence,toPacketEvidence,toReplyEvidence— three near-identical row-to-evidence mappers — into a sharedrowToEvidence(row, parseListFn, toImpactType)utilityDuplication: 47 → 43 clones, 750 → 716 lines, 2.145% → 2.044%
to*Evidencefunctions were triplicated code)content.tsBaselines lowered
Verification
pnpm quality— full gate passes (check, typecheck, coverage, docs, extension typecheck, all 7 health checks)pnpm test— 439 tests passProgress on #50