Fork me on GitHub

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


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 faster


and it's pretty idiomatic as well


Yea, 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.


Yeap, I think we can all agree on that one.

cjsauer17:04:28 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.