fix: warn and deduplicate on same-named Apex files across packages#290
Merged
Conversation
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>
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 Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
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>
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
buildFilePathCachepreviously 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.warningsarray and surfaces to the user through the existing warnings pipeline.Map<string, string>to{ cache: Map<string, string>; warnings: string[] }.Test plan
npm run test:only)SharedClass.cls— cache retains first-found path, warning emitted containing filename and"ignoring"buildFilePathCache.statFailure.test.tsupdated to destructure new return type🤖 Generated with Claude Code