Skip to content

fix: warn and deduplicate on same-named Apex files across packages#290

Merged
mcarvin8 merged 4 commits into
mainfrom
fix/cache-collision-duplicate-apex-files
May 29, 2026
Merged

fix: warn and deduplicate on same-named Apex files across packages#290
mcarvin8 merged 4 commits into
mainfrom
fix/cache-collision-duplicate-apex-files

Conversation

@mcarvin8
Copy link
Copy Markdown
Owner

Summary

  • buildFilePathCache previously had inconsistent deduplication: the full-filename key (AccountHandler.cls) was always overwritten by the last package directory scanned, while the no-extension key (AccountHandler) used a first-wins guard. Two packages with identically-named classes/triggers would silently produce wrong coverage data.
  • Both keys are now first-wins (consistent).
  • When a collision is detected, a warning is pushed to the returned warnings array and surfaces to the user through the existing warnings pipeline.
  • Return type changed from Map<string, string> to { cache: Map<string, string>; warnings: string[] }.

Test plan

  • Existing 103 unit tests pass (npm run test:only)
  • New test: two packages with SharedClass.cls — cache retains first-found path, warning emitted containing filename and "ignoring"
  • buildFilePathCache.statFailure.test.ts updated to destructure new return type

🤖 Generated with Claude Code

buildFilePathCache previously overwrote the full-filename cache key
(e.g. AccountHandler.cls) with each subsequent package directory scan,
while the no-extension key used a first-wins guard — inconsistent
behavior that silently dropped one file when two packages contained
identically-named classes or triggers.

Now both keys are first-wins. When a collision is detected, a warning
is added to the returned warnings array so it surfaces to the user via
the existing warnings pipeline. Updated return type from
Map<string, string> to { cache, warnings }.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@qltysh
Copy link
Copy Markdown

qltysh Bot commented May 29, 2026

All good ✅

Resolves qlty function-complexity and nested-control-flow findings.
Apex file registration logic moved to a dedicated helper, dropping
scanDirectory's cyclomatic complexity and maximum nesting depth.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/transformers/coverageTransformer.ts 100.00% <100.00%> (ø)
src/utils/buildFilePathCache.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

mcarvin8 and others added 2 commits May 29, 2026 09:04
Adds a test for the edge case where a .cls and .trigger file share the
same base name (e.g. Account.cls + Account.trigger). The no-extension
key is set by the first file processed; the second skips the set.
Brings branch coverage on buildFilePathCache.ts to 100%.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Resolves qlty function-many-parameters finding on processApexFile
(count = 6). Groups repoRoot, extensions, cache, and warnings into a
single ScanContext, reducing both scanDirectory and processApexFile
to two/three parameters.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mcarvin8 mcarvin8 merged commit be00604 into main May 29, 2026
11 checks passed
@mcarvin8 mcarvin8 deleted the fix/cache-collision-duplicate-apex-files branch May 29, 2026 13:08
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.

2 participants