Repository navigation
Fix cyclic-dependencies linter for comment forms - #2280
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes false positives in the clojure-lsp/cyclic-dependencies built-in linter where (require ...) calls inside (comment ...) forms were incorrectly contributing dependency edges and producing spurious cycles (issue #2107).
Changes:
- Add logic to remove dependency edges originating from
clojure.core/comment/cljs.core/commentregions before running cycle detection. - Add regression tests covering comment-form
require, including self-require and ensuring real cycles are still reported. - Add a CHANGELOG entry documenting the fix.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/src/clojure_lsp/feature/diagnostics/built_in.clj | Filters dep-graph edges that originate from namespace usages located inside (comment ...) bounds before cycle detection. |
| lib/test/clojure_lsp/feature/diagnostics/built_in_test.clj | Adds tests to ensure (require ...) inside (comment ...) does not create cycles, while real cycles remain detected. |
| CHANGELOG.md | Documents the linter fix in the Unreleased section. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Adjust the cyclic-dependencies linter to ignore dependencies originating from (require ...) calls inside (comment ...) forms. This prevents false positives in cycle detection while still allowing real cycles to be detected when present. Fixes clojure-lsp#2107
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.
The
cyclic-dependencieslinter falsely reported cycles caused by(require ...)calls inside(comment ...)forms. This change excludes those usages from cycle detection.Before running cycle detection, walk each file's analysis for
clojure.core/comment(andcljs.core/comment) var-usages, and decrement any dep-graph edges whose:namespace-usagesfall inside those bounds.It is scoped to the linter and other features are unchanged.
Fixes #2107
Checklist
docsfolder) — N/A, no user-facing setting changed