Fork me on GitHub
#clj-kondo
<
2022-12-15
>
Lyn Headley02:12:09

Can clj-kondo "learn" by reading locally defined specs and inferring lint rules from them?

Matthew Downey16:12:28

Is there a way to run clj-kondo.main from a babashka task? I know I can run clj-kondo https://github.com/clj-kondo/clj-kondo/blob/master/doc/jvm.md or as a https://github.com/clj-kondo/clj-kondo#babashka-pod, but from what I can tell the pod doesn't include the code in main. Ideally I'd be able to bb lint and have it replicate the behavior of clj-kondo --lint src, without the need to install the binary.

borkdude00:12:37

@UP7RM6935 You can use the pod to 1) install the binary for you and 2) call clj-kondo's API programmatically: (clj-kondo/run! {:lint ["src"]}) + clj-kondo/print! is the equivalent

Matthew Downey01:12:18

Oh wow thank you, that was easy 🙂

Matthew Downey01:12:17

(For anyone else: I just merged this into bb.edn)

{:pods {clj-kondo/clj-kondo {:version "2022.12.10"}}
 :tasks {:requires ([pod.borkdude.clj-kondo :as clj-kondo])
         lint (clj-kondo/print! (clj-kondo/run! {:lint ["src"]}))}}

ericdallo19:12:05

Would be valid to have a new linter that warns about functions with lots of arity? example:

(my-function a b c d e f g) ;; too-many-arguments - my-funciton should have at most 4 args

👀 1
ericdallo19:12:08

At Nubank it's pretty common to see calls passing components like:

(do-something my-data producer consumer http metrics)
where we'd prefer
(do-something my-data components) ;; components is a map with all those components

borkdude00:12:54

:max-fn-arity linter?