Skip to content

chore: reduce accepted code-health debt - #57

Merged
sarthakagrawal927 merged 1 commit into
mainfrom
fix/reduce-code-health-debt-50
Aug 15, 2026
Merged

chore: reduce accepted code-health debt#57
sarthakagrawal927 merged 1 commit into
mainfrom
fix/reduce-code-health-debt-50

Conversation

@sarthakagrawal927

Copy link
Copy Markdown
Member

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:

  • Extracted textFromSelectors(...selectors) helper to replace ??-chains of textFromSelector calls in all scraper functions (scrapePersonio, scrapeWorkable, scrapeLinkedIn, scrapeSmartRecruiters, scrapeGeneric)
  • Extracted firstScraperResult() to replace the 10-way ?? chain in scrape()

src/lib/local-storage.ts — 2 violations removed:

  • Extracted optionalJobFields(j) helper shared by toJobApplication (CCN 29→5) and toSummary (CCN 21→3), splitting the ?? chains across two smaller functions

src/lib/evidence-mapping.ts (new) — 3 violations removed:

  • Consolidated toEvidence, toPacketEvidence, toReplyEvidence — three near-identical row-to-evidence mappers — into a shared rowToEvidence(row, parseListFn, toImpactType) utility
  • Each caller now passes its own list-parser and impact-type resolver

Duplication: 47 → 43 clones, 750 → 716 lines, 2.145% → 2.044%

  • The evidence-mapping consolidation eliminated 4 clone groups (the three to*Evidence functions were triplicated code)
  • Scraper refactors reduced structural duplication in content.ts

Baselines lowered

- complexity: { violations: 81, ... }
+ complexity: { violations: 72, ... }

- duplication: { clones: 47, duplicatedLines: 750, percentage: 2.1453702909122114 }
+ duplication: { clones: 43, duplicatedLines: 716, percentage: 2.044254104211278 }

Verification

  • pnpm quality — full gate passes (check, typecheck, coverage, docs, extension typecheck, all 7 health checks)
  • pnpm test — 439 tests pass
  • No behavior changes: all refactors are extract-and-delegate, preserving exact semantics

Progress on #50

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
@sarthakagrawal927
sarthakagrawal927 merged commit 579c92b into main Aug 15, 2026
6 checks passed
@sarthakagrawal927
sarthakagrawal927 deleted the fix/reduce-code-health-debt-50 branch August 15, 2026 07:11
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