Fix usage scanner fixture false positives#862
Open
MANOJ-80 wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses false-positive phantom-dependency findings (notably PD001/PD002 under --check-overrides) by ensuring the usage scanner ignores imports that appear only in example/test/fixture directories, and adds regression tests to lock the behavior in.
Changes:
- Add a usage-scanner–specific exclusion set that extends the shared
EXCLUDED_DIRSwithexamples/,tests/,fixtures/,__tests__/, and__fixtures__/(plus singular forms). - Update both
scanProjectForPackageUsageandscanAllImportsto apply the new usage-specific directory exclusions. - Add regression tests covering scanner behavior and
buildOverrideContextintegration to ensure excluded directories don’t influenceimportedPackageNames.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/usage/scanner.ts |
Introduces USAGE_EXCLUDED_DIRS and applies it to directory traversal for both usage-scan entrypoints. |
tests/usage.test.ts |
Adds regression tests verifying example/test/fixture directories are excluded for both targeted and full import scans. |
tests/overrides/context-builder.test.ts |
Adds integration coverage ensuring override context import collection ignores excluded directories. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 #861
Summary
Verification
npm test -- tests/usage.test.ts tests/overrides/context-builder.test.ts tests/overrides/detectors/pd001.test.ts tests/overrides/detectors/pd002.test.ts --runInBand npm run build