Fork me on GitHub
#clj-kondo
<
2020-12-11
>
fmnoise10:12:59

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?

borkdude10:12:44

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.

lread17:12:48

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"}

dominicm17:12:22

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

dominicm17:12:31

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

borkdude17:12:03

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

lread17:12:02

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

lread17:12:29

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

lread17:12:52

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

dominicm17:12:10

It's not often what you intend.

lread17:12:33

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

dominicm17:12:40

Most common bug of this kind I see is:

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

dominicm17:12:52

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

borkdude18:12:30

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.

borkdude18:12:53

But I'll keep it in mind

lread18:12:09

Coolio! Thanks @borkdude.