refactor(money): drop the account-type parameter normalizeAmount never read - #105
Merged
Merged
Conversation
…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.
Owner
Author
Mutation gate: baseline comparison
Neither file regressed; one improved slightly. Killed and survived counts are identical across the board.
The overall 40.76% is dragged under by |
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.
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'saccountTypeMapparametersyncPlaidItemaccountsquery building that map — a DB read on every Plaid sync, whose result was thrown awayDeleting
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
accountTypeMapgone, ESLint immediately flaggedprocessBatch'shouseholdIdas unused — and it turns out it never was used. ESLint'sno-unused-varsdefaults toargs: "after-used", which only reports parameters following the last used one.accountTypeMapsat afterhouseholdIdand was used, so it masked it. Dropped as well.pnpm lintis now completely clean — zero problems, zero warnings.Tests
The 11
normalizeAmountunit 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 →0not-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:origin/main(11 unit tests)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 mutatessrc/lib/plaid/sync.ts, whose DB half is structurally no-coverage. See #103; compare against amainbaseline before treating it as a finding.🤖 Generated with Claude Code