Skip to content

fix(circular): strip comments before import scan, fixes self-import false positive#209

Merged
Wolfvin merged 1 commit into
mainfrom
fix/circular-comment-self-import-false-positive
Jul 11, 2026
Merged

fix(circular): strip comments before import scan, fixes self-import false positive#209
Wolfvin merged 1 commit into
mainfrom
fix/circular-comment-self-import-false-positive

Conversation

@Wolfvin

@Wolfvin Wolfvin commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Found while re-auditing CodeLens against a second real codebase (Coretax-Auto-Downloader KDS backend, vps-deploy/api/kds).

deps --check circular reported 2 "circular import" cycles, both self-loops on permission-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 by complexity_engine.py for the same class of false positive) before running the import-detection regexes.

Verified: total_cycles went from 2 (both false) to 0 (correct — KDS backend has no real circular imports).

@Wolfvin Wolfvin merged commit c89bb81 into main Jul 11, 2026
@Wolfvin Wolfvin deleted the fix/circular-comment-self-import-false-positive branch July 11, 2026 18:43
@chatgpt-codex-connector

Copy link
Copy Markdown

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.
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant