This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-13
Channels
- # admin-announcements (1)
- # announcements (40)
- # aws (2)
- # babashka (46)
- # babashka-sci-dev (106)
- # beginners (31)
- # cider (5)
- # circleci (2)
- # clj-kondo (48)
- # clojure (118)
- # clojure-belgium (1)
- # clojure-chicago (3)
- # clojure-europe (19)
- # clojure-ireland (3)
- # clojure-losangeles (2)
- # clojure-nl (2)
- # clojure-spec (10)
- # clojure-uk (4)
- # clojurescript (18)
- # community-development (5)
- # core-async (159)
- # cursive (16)
- # datomic (16)
- # etaoin (1)
- # fulcro (21)
- # funcool (14)
- # graalvm (5)
- # gratitude (4)
- # holy-lambda (28)
- # jobs (1)
- # jobs-discuss (1)
- # kaocha (1)
- # lsp (12)
- # malli (21)
- # meander (12)
- # music (1)
- # off-topic (8)
- # portal (5)
- # react (18)
- # reitit (1)
- # releases (4)
- # remote-jobs (1)
- # shadow-cljs (56)
- # timbre (4)
I'm writing a simple CLI tool that uses clj-kondo's analysis output. Working with clj-kondo has been very pleasant!
I'm trying to make things fast now, and I noticed that it doesn't seem any faster to run the analysis the second time, even though a cache is created in .clj-kondo
. Is this expected? How can I verify what clj-kondo is doing with the cache? I tried setting :debug true
but didn't see any extra output at all, so I'm probably holding it wrong
The analysis output itself isn't cached. The cache is used to look up info about other namespaces for linting: it's only used for functionality used by clj-kondo itself. If you want to do this as a user you should implement your own cache.
Going to add some linting for .clj-kondo/config.edn
. Any suggestions for common mistakes?
It's been pretty good so far, the one that caught me out recently was having a top-level key nested under another top-level key.
yes, I have a lint for that now :). see thread: https://clojurians.slack.com/archives/CHY97NXE2/p1642078177088700?thread_ts=1642078060.088600&cid=CHY97NXE2
clj-kondo 2022.01.13: a linter for Clojure code that sparks joy ✨
• Add linter `:conflicting-fn-arity`: warn when an arity occurs more than once in a function that overloads on arity. https://github.com/clj-kondo/clj-kondo/issues/1136 (https://github.com/mknoszlig)
• Add linter `:clj-kondo-config` which provides linting for `.clj-kondo/config.edn`. https://github.com/clj-kondo/clj-kondo/issues/1527
• Relax `:reduce-without-init` for functions known to be safe https://github.com/clj-kondo/clj-kondo/issues/1519
• Symbol arg to `fdef` can be arbitrary namespace https://github.com/clj-kondo/clj-kondo/issues/1532
• Improve potemkin generated var-definition analysis https://github.com/clj-kondo/clj-kondo/issues/1521 (https://github.com/ericdallo)
• Stabilize cache version independent from kondo version https://github.com/clj-kondo/clj-kondo/issues/1520. This allows you to re-use the cache over multiple kondo versions.
• :output {:progress true}
should print to stderr https://github.com/clj-kondo/clj-kondo/issues/1523
• Only print informative messages when `--debug` is enabled. https://github.com/clj-kondo/clj-kondo/issues/1514
• Add Sublime Text instructions https://github.com/clj-kondo/clj-kondo/issues/827 (https://github.com/KyleErhabor)
• Fix end location in anonyous function body https://github.com/clj-kondo/clj-kondo/issues/1533
• Bump datalog-parser to 0.1.9: allows symbol constants in datalog expression
was going through the default config just now and spotted https://github.com/clj-kondo/clj-kondo/blob/master/src/clj_kondo/impl/config.clj#L44-L45
@U08BJGV6E yes.. so?
I guess it would have caught it as an unknown linter. As of the linked commit, the key is in a position where a linter name should be
It doesn't catch that specific one since the expected names are derived from this config 😂
@ben.sless No, but the first reaction will be: do it as a configuration macro/hook and share it via clj-kondo.exports in the library
It's incredibly complicated with a ton of syntax and binding forms, wouldn't really know where to start
(m/rewrite {:a 'a :b nil :c 3}
{:a ?a :b ?b :c ?c}
{:a ?a
& ~[(if ?b [:b ?b])
(if ?c [:c ?c])]})
(rewrite expr & pairs)
left and right pairs are handled differently, lhs introduce bindings, rhs use bindings
Quoting: https://github.com/noprompt/meander/blob/epsilon/doc/operator-overview.md#escaping
Appreciate it. If it helps, this is what this would expand to:
(let*
[R__15723
(let*
[TARGET__15718 {:a 'a, :b nil, :c 3}]
(let*
[T__15721
(. TARGET__15718 valAt :c)
T__15720
(. TARGET__15718 valAt :b)
T__15719
(. TARGET__15718 valAt :a)]
(let*
[?a T__15719]
(let*
[?b T__15720]
(let*
[?c T__15721]
(let*
[form__12952__auto__ {:a ?a}]
(merge
(into {} cat [[(if ?b [:b ?b]) (if ?c [:c ?c])]])
form__12952__auto__)))))))]
(if (meander.match.runtime.epsilon/fail? R__15723) nil R__15723))
.clj-kondo/meander/epsilon.clj
:
(ns meander.epsilon
(:require [clojure.string :as str]
[clojure.walk :as walk]))
(defn collect-vars [expr]
(let [vars (volatile! [])]
(walk/postwalk (fn [x]
(when (and (symbol? x)
(str/starts-with? (str x) "?"))
(vswap! vars conj x))
x)
expr)
@vars))
(defmacro rewrite [expr & exprs]
(let [ret `(do ~expr
~@(map (fn [[lhs rhs]]
`(fn ~(collect-vars lhs)
~rhs))
(partition 2 exprs)))]
;; (prn ret)
ret))
.clj-kondo/config.edn
:
{:hooks {:macroexpand {meander.epsilon/rewrite meander.epsilon/rewrite}}}