Fork me on GitHub
#clj-kondo
<
2021-03-17
>
naomarik03:03:58

I joined just now to express my enormous appreciation for this library and how easy it's making my life. Thanks Michiel!

❤️ 3
Alex Whitt14:03:13

Has anyone gotten orchestra.core/defn-spec to work? I've seen some chatter about it on here, and it seems like you should just be able to do the following:

{:lint-as {orchestra.core/defn-spec clj-kondo.lint-as/def-catch-call}}
But that didn't work. @jfntn, did you ever get this working?

borkdude15:03:17

that config should work though

borkdude15:03:33

unless you are using a very old version of clj-kondo

Alex Whitt15:03:53

I'm on clj-kondo v2021.02.13

Alex Whitt15:03:44

Much obliged, thank you

Alex Whitt15:03:40

I'm on Spacemacs and I have the correct config AFAICT. It's still giving me "unresolved symbol."

borkdude15:03:42

@alex.joseph.whitt def-catch-all, not def-catch-call

Alex Whitt15:03:12

That was it! That'll teach me to copy-paste without double checking

Alex Whitt15:03:51

@borkdude, is it still expected that references to the defn-spec'd function would show "Unresolved var" warnings? Or should that work too?

borkdude15:03:49

Let me try...

borkdude15:03:48

Looks like it works correctly here:

borkdude15:03:33

You will need to re-visit your other buffer though in order for the cache to pick up your new vars

borkdude15:03:36

with your new config

Alex Whitt15:03:22

Might it make a difference that the var is in a local dependency lib through :local/root?

Alex Whitt15:03:54

Oddly it only shows up on one reference in the file, while other references to the same var don't complain

borkdude15:03:19

try clj-kondo --lint $(clojure -Spath) --parallel --no-warnings

borkdude15:03:52

that will lint your deps

borkdude15:03:02

and put the var info in your local cache

borkdude15:03:22

if you edit a local/root dep, that info doesn't end up in your project's cache, but in the other project's cache

Alex Whitt15:03:43

So I would have to re-run that to pick up changes in the dep, then?

Alex Whitt15:03:59

Alright, understood. I'm glad this all works.

borkdude15:03:25

you can also just lint clj-kondo --lint ../../the-other-local-root/whatever to update

borkdude15:03:56

if you want to sync

ericdallo16:03:31

@borkdude when clj-kondo adds :defined-by key to a var-definition analysis bucket?

ericdallo16:03:01

For a code like:

(defflow my-flow
   ....)
I want to know if the my-flow is defined-by defflow

ericdallo16:03:10

this already works with deftest

ericdallo16:03:32

Not sure this is related with defflow being a custom hook

ericdallo16:03:52

for other macros lke defn it doesn't add the defined-by

ericdallo16:03:48

My issue: I implemented on clojure-lsp the :exclude-when-defined-by on its custom linter https://clojure-lsp.github.io/clojure-lsp/settings/#unused-public-var, but it seems it doesn't work since clj-kondo don't send the defined-by for other symbols than deftest

borkdude16:03:39

yeah, we can add that. issue + PR welcome

👍 3
borkdude16:03:53

it's pretty much ad hoc I think

borkdude16:03:05

this is used by carve a lot to exclude "unused vars"

ericdallo16:03:44

I see, do you think we would add defined-by key to every var-definition?

borkdude16:03:42

what info do you actually want to have: - IF it was defined by something custom? - Or which thing it defined?

ericdallo16:03:32

which thing it defined, so we could compare with the provided exclude setting from user

ericdallo16:03:57

We already have that for deftest, I think is just make it work for other macros/functions ?

ericdallo18:03:15

@borkdude I started to implement that, is there any way to get the namespace and the symbol of the var on https://github.com/clj-kondo/clj-kondo/blob/master/src/clj_kondo/impl/analyzer.clj#L427? I only found call https://github.com/clj-kondo/clj-kondo/blob/master/src/clj_kondo/impl/analyzer.clj#L433 that only have the symbol name, not the ns

borkdude18:03:41

can you post this as a comment on the github issue? I'm losing track of all threads here in Slack...