Repository navigation
fix(javascript): omit self-referential import edges with disclosure - #1130
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
A specifier that resolves back to the importing module itself produced an imports edge from a module to itself, which the application graph schema forbids; one such specifier failed result validation and lost the whole analysis. Skip those edges at composition time and disclose the omission count in the graph limitations. Fixes morluto#1129
f33185b to
1cf4abf
Compare
|
Thanks for the PR and contribution! The self-import fix addresses the graph-validation failure well. I removed the unrelated Chinese README rewrite from this branch to keep this PR focused on #1129; that documentation change can be reviewed separately. I also strengthened the regressions into compiled CLI E2E tests and corrected the TypeScript extension-rewrite claim: All 38 focused tests and static checks passed, and a real CLI/stdio MCP probe returned matching results. Your authorship on the original fix is preserved. |
The self-import (#1130), async-chunk (#1152) and static-reference disclosures repeated one sentence template in three composers, and the new test repeated the analyze-and-check sequence of its neighbour. That put jscpd at its 2.5% threshold. Share the template through selfReferenceOmissions with identical wording, and share one test helper for the graph-wide self-reference invariants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ure (#1157) * fix(javascript): omit self-referential static references with disclosure A bundled module that requires its own key (`r(50)` inside webpack module 50) resolved, through the static-reference composer, to its own module node. The resulting self-referential imports edge failed result validation and lost the entire analysis ("Result schema rejected 1 issue ... (custom)"). This is the same invariant as #1146; #1152 fixed the bundler async-chunk composer, and this is the remaining adjacent composer. Skip a reference whose resolved target is its own source, count it, and disclose the omission the way #1152 discloses async-chunk references. Sibling requires are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * refactor(javascript): share the self-reference omission disclosure The self-import (#1130), async-chunk (#1152) and static-reference disclosures repeated one sentence template in three composers, and the new test repeated the analyze-and-check sequence of its neighbour. That put jscpd at its 2.5% threshold. Share the template through selfReferenceOmissions with identical wording, and share one test helper for the graph-wide self-reference invariants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…orluto#1130) * fix(javascript): omit self-referential import edges with disclosure A specifier that resolves back to the importing module itself produced an imports edge from a module to itself, which the application graph schema forbids; one such specifier failed result validation and lost the whole analysis. Skip those edges at composition time and disclose the omission count in the graph limitations. Fixes morluto#1129 * test(javascript): verify self-import behavior through the compiled CLI --------- Co-authored-by: BaaRai <baarai@users.noreply.github.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
…ure (morluto#1157) * fix(javascript): omit self-referential static references with disclosure A bundled module that requires its own key (`r(50)` inside webpack module 50) resolved, through the static-reference composer, to its own module node. The resulting self-referential imports edge failed result validation and lost the entire analysis ("Result schema rejected 1 issue ... (custom)"). This is the same invariant as morluto#1146; morluto#1152 fixed the bundler async-chunk composer, and this is the remaining adjacent composer. Skip a reference whose resolved target is its own source, count it, and disclose the omission the way morluto#1152 discloses async-chunk references. Sibling requires are kept. * refactor(javascript): share the self-reference omission disclosure The self-import (morluto#1130), async-chunk (morluto#1152) and static-reference disclosures repeated one sentence template in three composers, and the new test repeated the analyze-and-check sequence of its neighbour. That put jscpd at its 2.5% threshold. Share the template through selfReferenceOmissions with identical wording, and share one test helper for the graph-wide self-reference invariants. ---------
A webpack/Rspack chunk file that lazily requests one of its own chunk
ids (`__webpack_require__.e(<own id>)`, including merged multi-id
chunks) produced a bundler-async-chunk edge from the chunk to itself. A
bundled module that requires its own key (`r(50)` inside module 50) did
the same through the static-reference composer. The application graph
forbids self-referential edges, so one such edge failed result
validation and lost the entire analysis ("Result schema rejected ...
(custom)").
Apply the treatment morluto#1130 gave self-imports to both composers: skip the
edge, count it, and disclose the omission in the graph limitations. The
shared helper keeps the existing self-import wording.
Fixes morluto#1146
Summary
analyze_javascript_applicationpreviously lost the whole result when an import resolved to its own source module: composition emitted a self-referential module edge, which the graph schema rejects. Skip those edges and disclose their count in graph and result limitations. Import observations and their source evidence remain available; sibling imports and export-binding relationships are preserved.Fixes #1129.
Changes
./util.jswhen onlyutil.tsexists. The resolver currently does not perform this extension rewrite, so it is not counted as a self-import omission.CLI/MCP schemas and resolver behavior are unchanged.
Validation
npm run check:fastpassed.Local verification was performed on macOS. The contributor's larger monorepo example was not rerun in this review.