Fork me on GitHub
oxalorg (Mitesh)10:02:27

Hello! Thanks for all the awesome work on clj-kondo. I'm using it to get some analysis on my code base and then use rewrite-clj to modify it. So for example I want to get all the uses of a function called split lets say, so most of the normal analysis works. i.e. it finds the right usages of the function call and ignores the local scoped versions. But these quoted forms do not appear in :var-usages of the analysis, neither can I get clj-kondo to lint them:

(defn quoted-split []
  ;; does not work
  '(split "qu zu mu" #" "))

(eval (quoted-split))

;; does not work
((eval 'split) "qu zu mu" #" ")

(defmacro split-wrap [& body]
  ;; works 
  `(split ~@body))

(defmacro split-wrap2 [& body]
  ;; does not work
   '(split "a b c")
Anyone has an idea if this is something which is supported by clj-kondo? Thanks!!! 🌸


@mitesh quoted forms are just data, and that data doesn't necessarily use vars. It's impossible for clj-kondo to guess that this data will be used to refer to vars. In general, try to avoid eval .

💯 1
oxalorg (Mitesh)10:02:44

Yup that's what I thought. It makes complete sense to not try and lint/change quoted stuff as that is dangerous territory and we never really know what the user is doing.

oxalorg (Mitesh)10:02:04

Thanks for confirming this 🙌


If you write macros like:

(defmacro foo [] `(do ~split ...))
in that case clj-kondo will see the usage of split.

🚀 1

Btw, clj-kondo also has the ability to run macros via hooks, but you need to configure those

👍 1