This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-20
Channels
- # adventofcode (23)
- # announcements (4)
- # babashka (1)
- # beginners (37)
- # biff (2)
- # calva (1)
- # cider (19)
- # clj-kondo (11)
- # clojure (45)
- # clojure-bay-area (2)
- # clojure-europe (12)
- # clojure-nl (1)
- # clojure-norway (15)
- # clojure-uk (2)
- # clojurescript (8)
- # conjure (1)
- # cursive (17)
- # datomic (11)
- # garden (1)
- # graalvm (4)
- # hyperfiddle (21)
- # java (10)
- # jobs (3)
- # lsp (23)
- # off-topic (18)
- # polylith (2)
- # re-frame (4)
- # releases (1)
- # remote-jobs (3)
- # rewrite-clj (4)
- # squint (44)
- # uncomplicate (1)
- # xtdb (84)
Hi All, here is something small that is driving me crazy. I think I’m doing everything right with :lint-as
, but clj-kondo
is not linting the code for me. I’ll add details in the thread.
This is what my logging namespace is:
(ns logger.interface
(:require [io.pedestal.log :as log]
[jsonista.core :as json]))
(defmacro trace [& keyvals]
`(log/trace ::log/formatter json/write-value-as-string ~@keyvals))
(defmacro debug [& keyvals]
`(log/debug ::log/formatter json/write-value-as-string ~@keyvals))
(defmacro info [& keyvals]
`(log/info ::log/formatter json/write-value-as-string ~@keyvals))
(defmacro warn [& keyvals]
`(log/warn ::log/formatter json/write-value-as-string ~@keyvals))
(defmacro error [& keyvals]
`(log/error ::log/formatter json/write-value-as-string ~@keyvals))
It’s a wrapper over io.pedestal.log
to ensure that I can pass a ::formatter
option.
Now, when I use this code elsewhere, I want to ensure that I’m passing an even number of items to the call (so that & keyvals
is correct).
For this, I wrote the following in my config.edn
file:
{:lint-as {logger.interface/trace clojure.core/hash-map
logger.interface/debug clojure.core/hash-map
logger.interface/info clojure.core/hash-map
logger.interface/warn clojure.core/hash-map
logger.interface/error clojure.core/hash-map}}
This does not work, the linter does not give me errors when the number of forms are not even. It gives me the right error if I replace the logging macro call with hash-map
, so I know that clj-kondo itself is working.
My questions: 1. What am I doing wrong, if it’s something obvious? 2. What are the steps to debug this? How do I see what clj-kondo is doing?
My guess would be hash-map is a function, and kondo has specific support for it, where lint-as works by replacing analysis of an unknown macro with a known macro, but not sure
I removed the lint-as
and instead wrote a hook that I could use in analyze-call
. This took far more time than I wanted to spend on the task, but it’s working now the way I wanted it to.
Here is the change I made: https://github.com/pedestal/pedestal/pull/781/commits/fdbd52229ce9907bf8048f99a5c2bdd8d09e06c3
Looks like both .m2/repository/org/babashka/sci/0.8.41/sci-0.8.41.jar
and .m2/repository/clj-kondo/clj-kondo/2023.12.15/clj-kondo-2023.12.15.jar
contain clojure file named scratch.clj
that probably shouldn’t be part of the jar file. (Our project flags this as a conflict on the classpath). Should I file an issue about this?