This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-26
Channels
- # announcements (1)
- # asami (7)
- # aws (3)
- # babashka (30)
- # beginners (21)
- # calva (48)
- # cider (11)
- # clj-commons (5)
- # clj-kondo (12)
- # cljdoc (5)
- # cljfx (1)
- # cljs-dev (32)
- # cljsrn (4)
- # clojure (218)
- # clojure-europe (88)
- # clojure-nl (11)
- # clojure-uk (31)
- # clojurescript (8)
- # cursive (98)
- # data-science (6)
- # datomic (49)
- # emacs (12)
- # events (4)
- # fulcro (47)
- # graalvm (3)
- # graphql (4)
- # introduce-yourself (5)
- # java (13)
- # juxt (9)
- # lsp (74)
- # meander (3)
- # membrane (4)
- # missionary (31)
- # off-topic (24)
- # pathom (41)
- # portal (4)
- # reagent (3)
- # releases (1)
- # remote-jobs (3)
- # rewrite-clj (4)
- # shadow-cljs (10)
- # slack-help (2)
- # testing (20)
- # tools-deps (43)
I have one macro defined and used many times in one file that is throwing large numbers of "Unresolved symbol" warnings from clj-kondo. According to the documentation, one can configure clj-kondo with namespace local config usingĀ `:clj-kondo/config`Ā metadata in the namespace form. Is there an example of how to do this anywhere on the web? I've searched and can't seem to figure out where/how to put this metadata so it would effect the throwing of these warnings.
@U0DTU8J83 here is an example: https://clojurians.slack.com/archives/CHY97NXE2/p1643013321253200
Sure thing,. Let me know if you have any further questions. There's probably an even better solution for your macro, so if you give me some details, perhaps I can help you with that.
The macro gets passed a set of binding vars that get used in a let in the body of the macro. Each variable in the binding form generates one of the unresolved-symbol messages. In case it helps, here is the macro:
(defmacro expand [tag pnames err-check-fn err-check-msg fmt & fmt-args]
`{~(keyword tag) {:exp-fn
(fn [~'ss ~'rw]
(let [~pnames (:params ~'rw)]
(if (not (~err-check-fn ~'rw))
[(error (~err-check-msg ~'rw))]
((partial pp/cl-format nil ~fmt) ~@fmt-args))))}})
I think you could pretty much paste this macro in a file called .clj-kondo/macros.clj
and then add this to your configuration in .clj-kondo/config.edn
{:hooks {:macroexpand {foo.bar/expand macros/expand}}}
You will have to fully qualify pp/cl-format
to clojure.pprint/cl-format
No - it's complaining on the variables that get passed into pnames. Here's an example use of the macro:
(expand
"Eligibility Gate"
[coveragePeriod maxGaps maxGapDays type class]
#(= 5 (count (:params %)))
#(pp/cl-format nil "Wrong number of parameters in definition of ~a." (stringify (:name %)))
"define ~a: ~a(~a, ~a, ~a, ~a, ~a)"
(stringify (:name rw)) (stringify (:fn rw)) coveragePeriod maxGaps maxGapDays (unstring-null (s/lower-case type) "String") (unstring-null (s/lower-case class) "String"))
Its warning about the symbols coveragePeriod, maxGaps, maxGapDays, type, and class.ok, try the macro suggestion or else you can use the config for unresolved-symbol. the docs are here: https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#unrecognized-macros