This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-09-25
Channels
- # alda (7)
- # aleph (10)
- # announcements (3)
- # babashka (103)
- # beginners (54)
- # calva (62)
- # clerk (2)
- # clj-yaml (27)
- # cljs-dev (1)
- # clojure (61)
- # clojure-europe (64)
- # clojure-nl (3)
- # clojure-norway (34)
- # clojure-sweden (4)
- # clojure-uk (4)
- # conjure (9)
- # cursive (1)
- # data-science (3)
- # fulcro (20)
- # gratitude (1)
- # hyperfiddle (54)
- # lsp (9)
- # malli (7)
- # meander (4)
- # membrane (17)
- # off-topic (23)
- # releases (3)
- # sci (1)
- # shadow-cljs (5)
- # sql (1)
- # tree-sitter (8)
- # vim (6)
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])))