Fork me on GitHub
#clj-kondo
<
2019-06-17
>
genmeblog08:06:42

hi, I'm getting false positive in case when using multiarity multimethods (didn't found an issue on github)

genmeblog08:06:01

(defmulti testmulti (fn [m & _] m))
(defmethod testmulti :some
  ([_] "zero arity")
  ([_ _] "unary")
  ([_ _ _] "binary"))

genmeblog08:06:39

error: unsupported binding form ([_]"zero arity")

genmeblog08:06:52

linter is run from lein

borkdude09:06:29

ah multi-arity, yeah, thanks. I’ll make an issue for it

borkdude09:06:54

didn’t even know that was possible 🙂

genmeblog09:06:12

ha! 🙂 yes, and it's very convenient in some cases.

genmeblog09:06:38

another one:

genmeblog09:06:35

when def (or defn etc.) is emitted by macro:

(defmacro testmacro
  [symbol]
  `(def ~symbol 11))

(testmacro eleven)
I get: info: unresolved symbol eleven

borkdude09:06:42

that can be resolved using the following config:

{:lint-as {foo/testmacro clojure.core/def}}

borkdude09:06:53

if it uses the same syntax as def

genmeblog09:06:00

unfortunately not the same syntax

genmeblog09:06:11

but ok, I can live with it

borkdude09:06:13

or a subset of the syntax

borkdude09:06:35

is this the real macro or just an example?

genmeblog09:06:17

it was example, but here is the real one:

genmeblog09:06:48

the macro and following macro calls

genmeblog09:06:19

src\fastmath\regression.clj:98:25: info: unresolved symbol ols
src\fastmath\regression.clj:100:25: info: unresolved symbol rls
src\fastmath\regression.clj:102:25: info: unresolved symbol lasso
src\fastmath\regression.clj:102:39: info: unresolved symbol lambda
src\fastmath\regression.clj:102:46: info: unresolved symbol tolerance
src\fastmath\regression.clj:102:56: info: unresolved symbol max-iters
src\fastmath\regression.clj:108:25: info: unresolved symbol ridge
...

borkdude09:06:17

in that case I would use the config:

{:linters {:unresolved-symbol {:exclude [(wrap-regression)]}}}

borkdude09:06:32

that means it won’t report in a call to wrap-regression

borkdude09:06:16

for vars that are introduced by this macro, you can put in an extra declare (see example of HugSQL in the linked docs)

borkdude09:06:06

or if it just gets too annoying there is a way to turn off the linter in a namespace, but I haven’t documented this yet

genmeblog09:06:38

I think the best option is to use :exclude here, thank you

mynomoto17:06:05

Are edn files a valid target for clj-kondo?

borkdude17:06:49

@mynomoto since EDN is just a quoted clojure data structure, it could easily do that. What would be your use case for it?

borkdude17:06:45

for {:a 1 :a 2}:

$ clj-kondo --lint /tmp/foo.edn
/tmp/foo.edn:1:7: error: duplicate key :a
linting took 13ms, errors: 1, warnings: 0
but: {a 1 b 2}
$ clj-kondo --lint /tmp/foo.edn
/tmp/foo.edn:1:2: info: unresolved symbol a
/tmp/foo.edn:1:6: info: unresolved symbol b
linting took 10ms, errors: 0, warnings: 0
so it needs to read it as a quoted value, which would just be a small change

borkdude17:06:23

@mynomoto feel free to post a Github issue about it

mynomoto17:06:32

I did open a deps.edn file and clj-kondo warnings were all over it so I wanted to know if this was expected.

borkdude17:06:56

which editor integration are you using?

borkdude18:06:42

I think it makes sense to support this

borkdude18:06:08

but as of now, the editor integration should not lint .edn files. so I wonder which one you’re using

mynomoto18:06:54

Ale on vim.

mynomoto18:06:18

Ale works by filetype and I set edn as clojure because of syntax highlight

borkdude18:06:31

I’m not in control of that plugin. Does ale send the code over stdin or via the filesystem?

borkdude18:06:16

in other words: is there any way clj-kondo can see it’s dealing with a .edn file?

borkdude18:06:09

@mynomoto I’ll just implement it and let you know as soon as it’s there: https://github.com/borkdude/clj-kondo/issues/270