fix(circular): strip comments before import scan, fixes self-import false positive#209
Merged
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…alse positive
_parse_js_imports() regex-matched 'import ... from ...' anywhere in raw file
content, including inside // line comments and /* */ block comments. A file
with a usage-example comment referencing its own import path (e.g.
permission-gate.ts's docstring: '// import { requirePermission } from
../middleware/permission-gate') got flagged as importing itself, producing
a false-positive self-loop 'circular import' cycle.
Found via real-codebase validation (Coretax-Auto-Downloader KDS backend):
deps --check circular reported 2 cycles, both self-loops on
permission-gate.ts, ← both traced back to the same commented-out example
line, not real code.
Fix: reuse the existing _remove_comments() helper (already used by
complexity_engine.py for the same class of false-positive) before running
the import regexes.
|
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.



Found while re-auditing CodeLens against a second real codebase (Coretax-Auto-Downloader KDS backend, vps-deploy/api/kds).
deps --check circularreported 2 "circular import" cycles, both self-loops onpermission-gate.ts. Root cause: the file has a usage-example comment (// import { requirePermission } from '../middleware/permission-gate') documenting how callers should import it —_parse_js_imports()regex-matched this comment text as a real import statement, since it never strips comments first.Fix: reuse the existing
_remove_comments()helper (already used bycomplexity_engine.pyfor the same class of false positive) before running the import-detection regexes.Verified:
total_cycleswent from 2 (both false) to 0 (correct — KDS backend has no real circular imports).