This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-06
Channels
- # announcements (18)
- # asami (14)
- # aws (5)
- # babashka (58)
- # beginners (32)
- # calva (12)
- # cider (29)
- # clj-kondo (8)
- # cljfx (8)
- # cljs-dev (4)
- # clojure (101)
- # clojure-europe (54)
- # clojure-germany (5)
- # clojure-nl (8)
- # clojure-serbia (8)
- # clojure-spec (12)
- # clojure-uk (8)
- # clojurescript (24)
- # cursive (3)
- # datomic (17)
- # docs (2)
- # etaoin (12)
- # events (1)
- # fulcro (1)
- # google-cloud (2)
- # jobs (1)
- # jobs-discuss (6)
- # lsp (65)
- # luminus (2)
- # malli (10)
- # meander (4)
- # nrepl (1)
- # off-topic (112)
- # onyx (2)
- # pathom (6)
- # polylith (14)
- # re-frame (9)
- # reagent (36)
- # reitit (13)
- # releases (2)
- # remote-jobs (5)
- # rewrite-clj (12)
- # shadow-cljs (70)
- # specter (2)
- # startup-in-a-month (1)
- # xtdb (14)
Hey folks. Just checking if I’m not missing anything – is there any linter rule for avoiding thread macro abuse?
That is, catching things like (-> foo :bar)
(should be (:bar foo)
or (-> foo :bar :baz)
(prefer (get-in foo [:bar :baz])
)
Not clj-kondo, but fyi nonetheless https://github.com/jonase/kibit
I have a love-hate relationship with kibit. It has a couple helpful linters in it, but it’s really slow, and doesn’t support a lot of cljs syntax (which is what I work in most often). I imagine adding a linter to kondo that detects this issue would be really simple. Looking to see where this would go in the source code…
(-> foo :bar :baz) vs (prefer (get-in foo [:bar :baz]) )
can't say that I would endorse this, since the ->
variant is often fasterYea, I actually end up disagreeing with kibit on that exact case. Still, I think the trivial case of (-> foo :bar)
is safe to prefer (:bar foo)
. So the linter would check if you’re using ->
with only 2 args, and nothing fancier.
https://github.com/roterski/fulcro-rad-crux/blob/6baba4fcdf710ed801938067a1b5fe95ee39f8d6/src/main/roterski/fulcro/rad/database_adapters/crux/wrap_crux_save.clj#L103-L116 might change my mind on this linter. Sometimes it really is more readable to use a threading maco with only 2 args, like in the case of a reduce with a large reducing function.