Repository navigation
fix(javascript): omit self-referential static references with disclosure - #1157
Conversation
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>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
N0zoM1z0
left a comment
There was a problem hiding this comment.
Reproduced the self-require schema failure on the preceding fix, then independently passed 54 focused tests plus build/static checks here. The guard runs after worker projection, omits only an edge resolving to its own source, and discloses the count through both graph and result limitations. Sibling requires and original static observations remain available; the wording refactor preserves the existing import/chunk disclosures.
…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. ---------
Follow-up to #1152 (#1146), as described in the comment on #1152.
Problem
#1152 made
analyze_javascript_applicationsurvive a chunk requesting its own chunk ID. The same invariant ("Application graph edges cannot be self-referential") can still be reached through the static-reference composer,addReferenceinJavaScriptArtifactGraphFindings.ts. A bundled module that requires its own key resolves back to its own module node:On
main(after #1152),rea analyze-javascript-application <dir> --jsonreturns:{"code":"unreadable_output","details":{"operation":"analyze_javascript_application","reason":"Result schema rejected 1 issue at /edges/1 (custom)"}}Change
addReferenceskips a reference whose resolved target is its own source node, and counts it. This matches fix(javascript): preserve graphs with async chunk self-references #1152's async-chunk handling and fix(javascript): omit self-referential import edges with disclosure #1130's self-imports.addJavaScriptStaticFindingsreturns the disclosure, asaddJavaScriptBundlerNodesdoes since fix(javascript): preserve graphs with async chunk self-references #1152: "N static reference(s) resolved back to the referencing module itself and was/were omitted; application graph edges cannot be self-referential."r(51)from module 50, are kept.selfReferenceOmissionshelper with identical wording. The test file shares one helper for the graph-wide invariants. Together these keepjscpdunder its 2.5% gate (now 2.49%; adding a fourth copy of the template would have reached it).Other self-reference shapes don't produce self-edges and are unchanged, because they resolve to distinct nodes:
<script src>pointing at its own document;//# sourceMappingURL=naming its own file;Verification
tests/boundary/cli/javascriptBundlerSelfReferences.test.tsgains a compiled-CLI case. A module requiring itself and a sibling: no self-edges, one disclosed omission, and the siblingrequireedge kept. It fails onmain.analyze_javascript_application: 276 passed.npm run check:fast,npm run jscpdNo real Hopper or Ghidra verification was run, because this change does not touch those providers.
🤖 Generated with Claude Code