Skip to content

feat(core): orphan and reachability-based unused file detection#3

Merged
ElijahKotyluk merged 3 commits intomainfrom
feat/reachability-based-file-detection
Dec 18, 2025
Merged

feat(core): orphan and reachability-based unused file detection#3
ElijahKotyluk merged 3 commits intomainfrom
feat/reachability-based-file-detection

Conversation

@ElijahKotyluk
Copy link
Owner

@ElijahKotyluk ElijahKotyluk commented Dec 17, 2025

Changes:

  • Switch unused file detection to a dependency-graph approach
  • Files are now considered used if reachable from entry points via imports or re-exports
  • When no entry points are present, fall back to orphan-file detection
  • This fixes barrel modules and reduces false positives

@ElijahKotyluk ElijahKotyluk force-pushed the feat/reachability-based-file-detection branch 2 times, most recently from ca63e53 to b8af59f Compare December 17, 2025 17:52
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements reachability-based file detection to improve unused file detection by building a file dependency graph and checking reachability from entry points. When entry points are detected (via package.json exports or conventions), files are marked as unused only if they're unreachable from those entry points; otherwise, the system falls back to orphan detection for files with no incoming references.

Key Changes:

  • Enhanced entry point detection to parse package.json exports field (including conditional exports and arrays)
  • Implemented file dependency graph construction that tracks both import and re-export relationships
  • Added reachability analysis using graph traversal from entry points

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/integrate/barrel.test.ts Adds test verifying re-exported files aren't flagged as unused
tests/entrypoints/entrypoint-export.test.ts New test suite for package.json exports field parsing (string, conditional object, array formats)
src/core/usage/buildUsageGraph.ts Implements file dependency graph, reachability analysis, and module resolution logic for unused file detection
src/core/fileSystem/normalizePath.ts Refactors variable names for clarity (normalizeCache → normalizedFileCache, abs → absolutePath)
src/core/entrypoints/detectEntryPoints.ts Extends entry point detection to handle exports field, refactors mapping logic into separate functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ElijahKotyluk ElijahKotyluk changed the title Feat/reachability based file detection feat(core): orphan and reachability-based unused file detection Dec 17, 2025
@ElijahKotyluk ElijahKotyluk self-assigned this Dec 17, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ElijahKotyluk ElijahKotyluk force-pushed the feat/reachability-based-file-detection branch from 4dc811f to 4b402cb Compare December 17, 2025 18:12
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ElijahKotyluk ElijahKotyluk force-pushed the feat/reachability-based-file-detection branch from f414b50 to f4423ad Compare December 17, 2025 20:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ElijahKotyluk ElijahKotyluk marked this pull request as ready for review December 18, 2025 00:16
@ElijahKotyluk ElijahKotyluk merged commit 38ddddc into main Dec 18, 2025
1 check passed
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