Skip to content

Fix cyclic-dependencies linter for comment forms - #2280

Merged
ericdallo merged 2 commits into
clojure-lsp:masterfrom
jramosg:master
Apr 28, 2026
Merged

ericdallo merged 2 commits into
clojure-lsp:masterfrom
jramosg:master

Conversation

@jramosg

@jramosg jramosg commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

The cyclic-dependencies linter 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 (and cljs.core/comment) var-usages, and decrement any dep-graph edges whose :namespace-usages fall inside those bounds.

It is scoped to the linter and other features are unchanged.

Fixes #2107

Checklist

@ericdallo
ericdallo requested a review from Copilot April 27, 2026 19:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/comment regions 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

@ericdallo ericdallo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@ericdallo
ericdallo merged commit 4c4d80f into clojure-lsp:master Apr 28, 2026
13 of 14 checks passed
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.

cyclic-dependencies is over-zealous #1 in comment forms

3 participants