clj-kondo

https://github.com/clj-kondo/clj-kondo
borkdude 2021-03-01T13:48:02.059900Z

Anyone using clj-kondo in Cursive? Maybe you could explain @reefersleep in #lsp what it adds to Cursive.

👀 1
borkdude 2021-03-01T13:49:00.060200Z

Ah, you are here :)

tomd 2021-03-01T16:36:51.062200Z

I noticed today that the redefined-var linter picks up

(def foo 4)
(def foo 6)
but not
(let [bar 3]
  (def foo 4)
  (def foo 6))
is there a reason for not warning on the second example that I'm failing to see?

borkdude 2021-03-01T16:54:56.063500Z

@tomd This has to do with what clj-kondo considers to be a top level form. E.g. this works:

(comment
  (def foo 4)
  (def foo 6))
but for some of the other constructs it just assumes the user knows what they are doing or the vars are conditionally defined

tomd 2021-03-01T16:56:42.064Z

there's something beautifully optimistic about a linter assuming a user knows what they are doing 😆

tomd 2021-03-01T16:58:00.065600Z

but, yes, understood there will be some scenarios where that will be the case. I'm not sure let is often one of them - we have a few places in our codebase where we simply wrap a load of defs in a let to avoid lots of typing the same thing over and over.

borkdude 2021-03-01T17:01:09.067800Z

yeah, I think this could be improved

borkdude 2021-03-01T17:01:30.068300Z

it you want to have a stab at this, it's in analyze-children in clj-kondo.impl.analyzer

tomd 2021-03-01T17:06:09.069300Z

yes I'll create an issue and queue the work soon. just looking to add an exception for vars defined inside lets?

tomd 2021-03-01T17:07:17.070300Z

(maybe binding too? not sure if there are other things that usually wrap defs... :thinking_face: )

borkdude 2021-03-01T17:08:02.070500Z

I think let is the most common

👍 1