fix(ingestion): rescue local Express route middleware from unused-export detection#386
Open
joptimus wants to merge 1 commit into
Open
fix(ingestion): rescue local Express route middleware from unused-export detection#386joptimus wants to merge 1 commit into
joptimus wants to merge 1 commit into
Conversation
…ort detection
Same-file middleware passed by bare name to a route registration
(router.post("/x", logRequest, handler)) is never seen by the import
graph, so the exports were flagged as dead. Detect route registrations on
express()/Router()-initialised receivers and emit a reads edge from the
file's ::__module__ symbol to each local-function argument, sourced there
to avoid clobbering the file->symbol defines edge in the single-edge graph.
A balanced-paren scan handles multiline calls and middleware factories
before the handler; string literals are stripped so route paths can't be
mistaken for identifiers.
|
✅ Health: 7.0 (unchanged)
🔥 Hotspots touched (2)
📊 Full report · ⭐ Star Repowise · 📥 Install bot · Last updated 2026-06-05 20:51 UTC |
cbb7805 to
104c882
Compare
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
express()/Router()-initialised receivers and emit areadsedge from the file's::__module__symbol to each same-file middleware function passed by bare name, so local route middleware is no longer reported as an unused export.::__module__(not the file node) to avoid clobbering the existing file→symboldefinesedge in the single-edgeDiGraph; a balanced-paren scan handles multiline calls and middleware factories before the handler, and string literals are stripped so route paths aren't mistaken for identifiers.express()/Router()receivers (e.g.cache.get(fn)) are left untouched.Related Issues
Fixes #373
Test Plan
pytest) —tests/unit/ingestion/test_express_framework_edges.py(11 passed);tests/unit/analysis tests/unit/dead_code tests/unit/ingestion+ TS/CommonJS dead-code integration (1303 passed, 2 xfailed)ruff check .)npm run build) (no frontend changes)New coverage: route-method reads edges,
app.usemiddleware,defines-edge preservation, nested middleware-factory args, the.js/CommonJS multilinerouter.post(...)shape from #373, non-route receivers in an Express file, non-Express files gated out, and a dead-code regression proving the middleware exports are no longer flagged.Checklist