clj-kondo

https://github.com/clj-kondo/clj-kondo
fmnoise 2020-12-11T10:21:59.109600Z

Hi everyone, small question: using both kondo and joker in emacs currently, but thinking about getting rid of joker. Is kondo a full replacement currently or still better to keep 2 linters?

borkdude 2020-12-11T10:23:44.111200Z

I have been running joker alongside clj-kondo (since I started with joker and then was inspired to build clj-kondo) and I think it would be safe to say that clj-kondo covers 99% of joker and offers a ton more linters. There might be very minor things like (let []) (warn on empty body in let) that are not in clj-kondo due to nobody asking for it but those are easy to add.

fmnoise 2020-12-11T10:24:45.111700Z

thanks a lot @borkdude!

lread 2020-12-11T17:13:48.115300Z

Naive question: Is the fact that a dissoc on a record’s field returns a map instead of a record lint-worthy? Or is this something folks do normally and intentionally?

(defrecord MyRecord [field1 field2])
(def r (->MyRecord "22" "23"))
(dissoc r :not-a-field)
;; => #user.MyRecord{:field1 "22", :field2 "23"}
(dissoc r :field1)
;; => {:field2 "23"}

dominicm 2020-12-11T17:24:22.115400Z

@lee detectign the type seems hard 99% of the time

dominicm 2020-12-11T17:24:31.115500Z

Although it'd be useful in the "this" case of a record

borkdude 2020-12-11T17:26:03.115900Z

@lee What lint warning would you expect in which example?

lread 2020-12-11T17:28:02.117800Z

I was thinking the second dissoc might warn “a dissoc on a record returns a map”

lread 2020-12-11T17:29:29.119800Z

I was not thinking of a warning on the first dissoc... was just trying to show a record was returned in that case.

lread 2020-12-11T17:31:52.121400Z

but maybe wanting to convert a record to a map in this way is a normal thing? I am too naive to know. 🙂

dominicm 2020-12-11T17:35:10.121600Z

It's not often what you intend.

lread 2020-12-11T17:39:33.123Z

Good to know, @dominicm, thanks, (dec lread-naiveness)

dominicm 2020-12-11T17:41:40.123100Z

Most common bug of this kind I see is:

(defrecord DBComponent [conn-opts db]
  component/Lifecycle
  (start [this] …)
  (stop [this] (dissoc this :db)))

dominicm 2020-12-11T17:41:52.123200Z

I don't remember if it matters in that exact position, but I think it's warned about.

borkdude 2020-12-11T18:22:30.123900Z

Maybe this is more a case for clojure.spec since for clj-kondo it's not impossible but hard to know what dissoc on something is going to return and if this is or is not intended.

borkdude 2020-12-11T18:24:53.124200Z

But I'll keep it in mind

lread 2020-12-11T18:35:09.125100Z

Coolio! Thanks @borkdude.