clj-kondo

https://github.com/clj-kondo/clj-kondo
verma 2020-06-25T05:30:51.053100Z

hello everyone, I am trying to lint a defrecord but it seems like I am not getting unresolved vars reported, I am trying this snippet in the lint playground:

(+ a b)

(defrecord wow [a b]
  (some [_]
        (+ a b whatisthis)))

verma 2020-06-25T05:31:29.054Z

I can get a and b to report correctly in my first statement, but whatisthis is not being reported as unrecognized/unresolved

verma 2020-06-25T05:37:19.054200Z

oof

verma 2020-06-25T05:37:53.054800Z

I think there is some syntax problem, I cannot declare that function some without an interface/symbol of somekind

verma 2020-06-25T05:38:50.055100Z

Trying with this now:

(+ a b)


(defprotocol IAbc
  (doit [_]))

(defrecord abc [a b]
  IAbc
  (doit [_]
    (+ a b whatisthis)))

verma 2020-06-25T05:41:59.055400Z

still doesn't seem like its being reported, am I missing something?

borkdude 2020-06-25T05:57:19.058300Z

@verma clj-kondo might not have good analysis yet for the protocols part of defrecord, I’ll take a look when I’m at a keyboard

verma 2020-06-25T05:58:03.058800Z

thanks @borkdude :thumbsup:

verma 2020-06-25T06:01:02.059400Z

I am trying to write an analyzer for defcomponentk from https://github.com/plumatic/om-tools/blob/master/src/om_tools/core.cljc#L257 using the new :hooks stuff in clj-kondo

borkdude 2020-06-25T08:01:46.061Z

@verma awesome! I checked and clj-kondo has pretty crude analyzing for defrecord's protocol parts at the moment. it basically lints it, with some things turned off. https://github.com/borkdude/clj-kondo/blob/466930149b0c8c3b50fab0df5c6d2fb482a03cb8/src/clj_kondo/impl/analyzer.clj#L926 There is room for improvement there, but now you know why it is like it is.

borkdude 2020-06-25T08:03:55.061600Z

There is an old issue for it: https://github.com/borkdude/clj-kondo/issues/140 But I never got to it yet.

borkdude 2020-06-25T08:04:22.062200Z

Meanwhile I did implement protocols in babashka/sci, so at least I have more understanding of it now 😉

borkdude 2020-06-25T08:05:28.062600Z

Bumped it a little bit in the "medium priority" column: https://github.com/borkdude/clj-kondo/projects/1

verma 2020-06-25T17:36:33.062800Z

thanks so much!