Skip to content

refactor(money): drop the account-type parameter normalizeAmount never read - #105

Merged
KenTaniguchi-R merged 1 commit into
mainfrom
fix/92-drop-unused-account-type
Aug 30, 2026
Merged

refactor(money): drop the account-type parameter normalizeAmount never read#105
KenTaniguchi-R merged 1 commit into
mainfrom
fix/92-drop-unused-account-type

Conversation

@KenTaniguchi-R

Copy link
Copy Markdown
Owner

Closes #92 — see the rescope comment; the ESLint half of that issue already landed on main, so this is the remaining real finding.

The parameter

normalizeAmount(amountCents, _accountType) took an account type it never read. Plaid applies one sign convention across every account type, so normalization genuinely does not depend on one — and a parameter implying it does is misleading right next to the sign-convention work in #84/#95.

What removing it exposed

The parameter was the only consumer of a chain that existed solely to feed it:

  • processBatch's accountTypeMap parameter
  • the map construction in syncPlaidItem
  • the accounts query building that map — a DB read on every Plaid sync, whose result was thrown away

Deleting normalizeAmount's parameter without deleting this chain would have left an unused parameter behind, which is the exact smell being fixed, so the chain goes too.

A second dead parameter, previously hidden

With accountTypeMap gone, ESLint immediately flagged processBatch's householdId as unused — and it turns out it never was used. ESLint's no-unused-vars defaults to args: "after-used", which only reports parameters following the last used one. accountTypeMap sat after householdId and was used, so it masked it. Dropped as well.

pnpm lint is now completely clean — zero problems, zero warnings.

Tests

The 11 normalizeAmount unit tests were one assertion repeated per account-type string ("checking", "credit", "investment", "savings", "loan", "depository", "other") — a distinction the signature can no longer express. Collapsed to the three behaviours that actually differ: positive → negative, negative → positive, and zero → 0 not -0. The two property tests lost their account-type loops.

Verified this costs no coverage rather than assuming it. Stryker on money.ts, before and after:

killed survived no-cov score
origin/main (11 unit tests) 78 24 0 76.47%
this branch (3 unit tests) 78 24 0 76.47%

Identical. The 8 removed tests killed nothing the remaining ones don't.

Full suite green: 744 passed / 113 files (752 → 744 is exactly the 8 collapsed cases). Typecheck and lint clean.

⚠️ mutation (diff) will likely report red — it also mutates src/lib/plaid/sync.ts, whose DB half is structurally no-coverage. See #103; compare against a main baseline before treating it as a finding.

🤖 Generated with Claude Code

…r read

normalizeAmount(amountCents, _accountType) took an account type it never
used. Plaid applies one sign convention across every account type, so
normalization does not depend on one -- and a parameter implying it does
is misleading next to the sign-convention work in #84/#95.

Removing it orphaned the whole chain that existed only to supply it:

- processBatch's accountTypeMap parameter
- the map construction in syncPlaidItem
- the accounts query feeding that map, a DB read on every Plaid sync

That in turn unmasked a second dead parameter. processBatch's
householdId was never used either, but ESLint's `args: "after-used"`
default only reports parameters following the last used one, so
accountTypeMap was hiding it. Dropped as well.

`pnpm lint` is now completely clean -- zero problems, zero warnings.

The 11 normalizeAmount unit tests were the same assertion repeated once
per account-type string, a distinction the signature can no longer
express. Collapsed to the three behaviours that actually differ
(positive, negative, zero-not-negative-zero) and de-looped the two
property tests. Verified this costs nothing: money.ts mutation score is
76.47% (78 killed / 24 survived) both before and after, unchanged.

Closes #92.
@KenTaniguchi-R

Copy link
Copy Markdown
Owner Author

Mutation gate: baseline comparison

file origin/main this PR delta
money.ts 76.47% — 78 killed, 24 survived, 0 no-cov 76.47% — 78 killed, 24 survived, 0 no-cov unchanged — and above the 60 threshold on its own
plaid/sync.ts 7.27% — 8 killed, 7 survived, 95 no-cov, 124 err 7.34% — 8 killed, 7 survived, 94 no-cov, 119 err marginally up, from deleting dead code

Neither file regressed; one improved slightly. Killed and survived counts are identical across the board.

money.ts — the file this PR actually changes in substance — passes the threshold comfortably, and the CI number matches the local before/after measurement exactly (76.47%, 78/24/0/27), which also confirms collapsing those 8 redundant tests cost nothing.

The overall 40.76% is dragged under by plaid/sync.ts's structural 7%: 94 of its 109 non-error mutants are no-coverage because its DB half is unreachable under vitest.stryker.config.ts. That is #103, and it is unchanged by this PR — the PR only deletes code there.

Merging on the same basis as #102 and #104.

@KenTaniguchi-R
KenTaniguchi-R merged commit 5a9b1b0 into main Aug 30, 2026
4 of 5 checks passed
@KenTaniguchi-R
KenTaniguchi-R deleted the fix/92-drop-unused-account-type branch August 30, 2026 01:10
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.

normalizeAmount takes an _accountType parameter it never reads

1 participant