Fork me on GitHub

Hello all, I´m using Atom with clj-kondo, and, is this used to fix the warning/error from editor too, or only to tell?


Linters just tell you what is wrong. How you fix them is up to you 🙂


I thought it was click to fix integration like in Visual Studio :-)


I've never been comfortable with tools changing my code!


To be fair, IntelliJ IDEA's autofixes are numerous and extremely useful on the Java side. The bigger problem however is that there might be several potential fixes to any single issue highlighted by the linter, so choosing just one is quite a task... 🙂 Definitely would be an interesting extension project to create though, that is, read in clj-kondo's linting metadata and provide automatic refactoring actions based on those.


Is the cond->> expression meant to be supported? I tried doing something like this, but assoc gives an lint error:

(cond->> initial-map
  (some? x) (assoc :foo bar))



$ clj -e "(cond->> {} (some? 1) (assoc :foo 1))"
Execution error (ClassCastException) at user/eval137 (REPL:1).
clojure.lang.Keyword cannot be cast to clojure.lang.Associative
$ clj-kondo --lint - <<< "(cond->> {} (some? 1) (assoc :foo 1))"
<stdin>:1:30: error: Expected: associative collection or nil, received: keyword.
linting took 10ms, errors: 1, warnings: 0
That seems to be accurate?


ah interesting, trying it in repl this works:

(cond-> {:x "foo"} 
  true (assoc :y "bar"))
result: {:x "foo", :y "bar"} this doesn’t:
(cond->> {:x "foo"} 
  true (assoc :y "bar"))
error: class clojure.lang.Keyword cannot be cast to class clojure.lang.Associative so i guess it’s not a bug in clj-kondo since clojure throws an error too (thanks for checking it, btw). but unless i’m using cond->> incorrectly looks to be a bug in clojure


@alidcastano It's not a bug in Clojure:

user=> (require '[clojure.walk :refer [macroexpand-all]])
user=> (macroexpand-all '(cond->> {:x "foo"} true (assoc :y "bar")))
(let* [G__143 {:x "foo"}] (if true (assoc :y "bar" G__143) G__143))


so cond-> evaluates it to (assoc G__143 :y "bar") but cond->> evaluates it to (assoc :y "bar" G__143) 😅


cond->> is thread last so it threads your expression into the last position in the assoc call: (assoc :y "bar" data) which is incorrect usage.

✔️ 4

thanks for further clarifying, i do see now that official Clojure docs state that ->> is the thread last macro. I was reading the cond->> docs in and incorrectly inferred this was the only difference: threading does not short after the first expression