clj-kondo 2025-10-23

I'm introducing a :duplicate-key-in-assoc linter in the next version of clj-kondo. I wonder if I should generalize this linter (name). It could also be applied to dissoc et. al. More examples of this? It would catch (assoc {} :foo 1 :foo 2)

(merge {:foo 1} {:foo 2}) also I would generalize name as "argument-shadowing"

argument-shadowing is something else imo:

(fn [x] (let [x 1]))
I think it should at least contain the word "key"

depends, for example (conj #{} 1 1)

you're adding twice the same key into the set, I'd say :) :duplicate-key-.... I'm looking for the word on the dots

nice find. that was a find and replace operation i think. :dataset true -> :type :model

oh 🙂 I know a good example that is not about keys at all:

(cond
  (map? x) {:foo 1}
  (map? x) {:bar 2})

:duplicate-key-argument?

@delaguardo that example wouldn't be duplicate if map? was a side effecting function (which in this case it isn't). I guess the same would go for assoc + dynamic key functions

so maybe I'd have to restrict this to constant keys

I guess the same would go for assoc + dynamic key functions
or mutable object implementing IPersistentMap on a second thought, this is the same thing 🙂

duplicate-key-in-call... maybe?

I'll stop overthinking and just add this one focused feature

this issue bit me once so I wrote up an issue for it

@dpsutton feel free to close my pr and just patch it yourself, don't have time to go through all kinds of checks :)

will do. thanks for highlighting