Should I use guard clauses in scan to ensure that these values aren't both nil?
;; Want to filter nils, such that both ?from and ?to are populated
(m/search clj-kondo-analysis
{:var-usages (m/scan {:from-var ?from :name ?to})}
[?from ?to])
If so, where should I put the clauses? I am having a bit of trouble finding syntax examples with scan. Should I be using a different technique?
This is how I structure the data:
(def analysis (:analysis (clj-kondo/run! {:lint paths
:config {:analysis {:var-usages true
:var-definitions {:shallow false}}}
:skip-lint true})))
This is a simplified dataset that I am working with:
[{:name ->evdev,
:from-var -main}
{:name ->joydev,
:from-var -main},
{:name defn
:from-var nil}]
I think I figured it out!
(m/search (:analysis analysis)
{:var-usages (m/scan {:from-var ?from
:name ?to
& (m/guard (not= ?from nil))})}
[?from ?to])Woooot, got it working!!!! Ubergraph + Meander ❤️
(def multigraph (apply uber/multidigraph
(m/search (:analysis analysis)
{:namespace-definitions (m/scan {:name ?ns :as ?rest})
:var-usages (m/scan {:from-var ?from
:name ?to
:to ?ns
& (m/and (m/guard (not= nil ?from))
(m/guard (not= nil ?to)))
:as ?var-rest})}
[?from ?to ?var-rest])))