clj-kondo

https://github.com/clj-kondo/clj-kondo
Kevin 2020-09-25T17:43:37.011300Z

eslint has a way to pass --fix which will auto fix errors that don't require programmer intervention. Is there a way to do this with clj-kondo?

borkdude 2020-09-25T17:56:20.011800Z

no, clj-kondo won't touch your code

borkdude 2020-09-25T18:04:18.012200Z

there are various tool that can, but they are mostly tied to editors, e.g. clj-refactor, clojure-lsp, etc

borkdude 2020-09-25T18:04:48.012600Z

this is a tool that cut out unused vars: https://github.com/borkdude/carve

Kevin 2020-09-25T18:56:12.015700Z

how would I configure linters when I'm using this library https://github.com/plumatic/plumbing . I want to use the :lint-as option instead of excluding it like this:

{:linters
  {:unresolved-symbol
    {:exclude [(plumbing.core/fnk)]}}}

borkdude 2020-09-25T19:26:02.016200Z

@kevin26428 I think this works:

(ns foo
  {:clj-kondo/config '{:lint-as {plumbing.core/fnk clojure.core/fn}}}
  (:require [plumbing.core :refer (fnk sum)]))

(def stats-graph
  "A graph specifying the same computation as 'stats'"
  {:n  (fnk [xs]   (count xs))
   :m  (fnk [xs n] (/ (sum identity xs) n))
   :m2 (fnk [xs n] (/ (sum #(* % %) xs) n))
   :v  (fnk [m m2] (- m2 (* m m)))})

borkdude 2020-09-25T19:27:04.016400Z

so {:lint-as {plumbing.core/fnk clojure.core/fn}}

Kevin 2020-09-25T19:51:49.016500Z

Thanks!

Kevin 2020-09-25T20:01:28.017300Z

I didn't see any mention of white space or indentation space checks in clj-kondo, is this configurable?

borkdude 2020-09-25T20:04:53.017500Z

clj-kondo ignores all whitespace - I think there might be other tools concerned with formatting / indentation

borkdude 2020-09-25T20:06:08.018400Z

I think it could do that, but personally I haven't really found this an issue worthwhile to work on, since formatting in the editors I use is pretty much automatic

NoahTheDuke 2020-09-25T20:19:42.019900Z

i have a macro called wait-for that does a lot (too much probably). i have it listed in the :invalid-arity {:skip-args vector. because of this, i have an "unused binding" warning. if I remove the wait-for from the :skip-args vector, the "unused binding" warning goes away (as it should, because the binding is used inside the wait-for call)

NoahTheDuke 2020-09-25T20:21:19.020500Z

any ideas why this might be happening?

borkdude 2020-09-25T20:40:16.020800Z

@nbtheduke Do you have a repro for me to look at?

borkdude 2020-09-25T21:16:19.021300Z

@nbtheduke E.g.:

(ns foo)

(defmacro wait-for [& _body])

(defn foo [x]
  (wait-for (inc x 1 2 3)))
$ clj-kondo --lint /tmp/foo.clj --config '{:linters {:invalid-arity {:skip-args [foo/wait-for]}}}'
linting took 11ms, errors: 0, warnings: 0

borkdude 2020-09-25T21:16:32.021700Z

I don't see x being unused

NoahTheDuke 2020-09-25T21:17:42.022300Z

others is referenced on line 265

borkdude 2020-09-25T21:19:01.023500Z

Can you boil this down to a small repro?

NoahTheDuke 2020-09-25T21:19:15.023800Z

lol I'll see what I can do. this repo is a mess

Kevin 2020-09-25T22:52:23.024700Z

how do i exclude/handle things like tags #db/fn