Fork me on GitHub
#clj-kondo
<
2023-05-26
>
diego.videco01:05:18

I am trying to analyze a macro call, but I can’t seem to get it completely right: I’ve got this:

(defn defsynth [{:keys [children]}]
  (let [[_ synth-name binding-vec & body] children
        new-node (api/list-node
                  (list*
                   (api/token-node 'def)
                   synth-name
                   [(api/list-node
                     (list*
                      (api/token-node 'let)
                      binding-vec
                      body))]))]
    {:node new-node}))
The macro looks like this:
(o/defsynth rev [in 0 out 0 mix 0.5 room 0.8 damp 0.5 amp 1]
  (o/out out (* amp (o/free-verb (o/in in) mix room damp))))
And the hook output looks like this:
{:node <list: (def rev (let [in 0 out 0 mix 0.5 room 0.8 damp 0.5 amp 1] (o/out out (* amp (o/free-verb (o/in in) mix room damp)))))>}
It works for defining the vector symbols, but in the places I use it, rev still appears to not be defined. Also it doesn’t show if there are unused symbols in the let binding or if undefined symbols are used in the body. Though what I really want is to have rev understood as being defined.

👍 2
borkdude09:05:40

Are you using the newest version of clj-kondo?

borkdude09:05:02

Try with

clj-kondo --lint <src> --debug
on the command line. My suspicion is that some list node is not constructed correctly

borkdude09:05:40

also I find it suspicious that you're destructuring on children and not on node or is there another function which receives the node?

diego.videco18:05:55

I am using this version: “2023.04.15-SNAPSHOT” (on emacs doom, with clojure-lsp)

diego.videco18:05:23

I also find int suspicious that I am destructing on children, but that’s what I am getting from this:

(-> (api/parse-string
       "(o/defsynth rev [in 0 out 0 mix 0.5 room 0.8 damp 0.5 amp 1]
  (o/out out (* amp (o/free-verb (o/in in) mix room damp))))")
      defsynth)
Am I perhaps doing something wrong?

diego.videco18:05:34

Oh got it, I had to wrap the output of parse-string in a hash-map with the :node key

borkdude10:05:45

@fergalbyrne You or your colleague (don't know their name, sorry) asked about midje + clj-kondo at the Funding Circle meetup. I noticed there is an exported configuration in midje here: https://github.com/marick/Midje/tree/master/test-resources/clj-kondo.exports/marick/midje

fergalbyrne16:10:33

Hey @U04V15CAJ sorry only seeing this now. Yes, that was almost certainly me.. Wow, that is enormously useful, and also shows how to extend/adapt it. It’ll have to be for my next job (we just both finished up with YouView, they’re more or less abandoning Clojure and the type of straightforward people who tend to use it).

👍 1
borkdude17:05:05

https://github.com/clj-kondo/clj-kondo: static analyzer and linter for Clojure code that sparks joy Just a few bugfixes since the last release! 2023.05.26 • https://github.com/clj-kondo/clj-kondo/issues/2083: fix regression with :missing-test-assertion introduced in 2023.05.18 • https://github.com/clj-kondo/clj-kondo/issues/2084: add :refers to :refer-all finding • https://github.com/clj-kondo/clj-kondo/issues/2086: false positive missing test assertion with swap!https://github.com/clj-kondo/clj-kondo/issues/2087: honor :config-in-comment for :unused-referred-var