Skip to content

Reader macros in :require blocks cause crashes and lose association with target dependencies #111

@scgerkin

Description

@scgerkin

Problem 1:
When adding a reader macro attached to a required namespace, the reader macro is treated as its own element rather than a comment on the namespace. This means the reader macro will be sorted as an element and no longer attached to the namespace.

Before:

(ns my-ns
  (:require
    [a.b]
    #_:clj-kondo/ignore
    [c.d]))

After:

(ns my-ns
  (:require
    #_:clj-kondo/ignore
    [a.b]
    [c.d]))

Problem 2:
Complex reader macros such as #_{:clj-kondo/ignore [:discouraged-namespace]} will cause cljstyle to crash with an exception.

Example:

(ns my-ns
  (:require
    [a.b]
    #_{:clj-kondo/ignore [:discouraged-namespace]}
    [c.d]))

Exception:

Error while processing file my_file.clj
Formatter threw IllegalArgumentException at position 1:1 while calling cljstyle.format.ns/rewrite-ns
Failed to process 1 files

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions