Skip to content

False positive when discouraging read-string in combination with macroexpand hook #2466

@imrekoszo

Description

@imrekoszo
  • I have read the Clojure etiquette and will respect it when communicating on this platform.

version

; clj-kondo -version | head -n 1
clj-kondo v2025.01.16

macro usage

Yes

platform

macos, homebrew

problem

When discouraging clojure.core/read-string, macroexpanding a macro, and using a tagged literal within that macro, a read-string warning is presented.

repro

echo '(ns foo (:require clojure.template)) (clojure.template/do-template [_] #a/b 1 2)' | clj-kondo --config '{:linters {:discouraged-var {clojure.core/read-string {}}} :hooks {:macroexpand {clojure.template/do-template clojure.template/do-template}}}' --lint -

config

{:linters
 {:discouraged-var {clojure.core/read-string {}}}
 :hooks
 {:macroexpand {clojure.template/do-template clojure.template/do-template}}}

source code

(ns foo (:require clojure.template))

(clojure.template/do-template [_] #a/b 1 2)

expected behavior

No warning is displayed about read-string.

additional info

From @borkdude on Slack:

I don't think this is related to do-template at all but something in rewrite-clj

user=> (rewrite-clj.node/sexpr (p/parse-string "#bar/x []"))
(read-string "#bar/x []")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions