clj-kondo

https://github.com/clj-kondo/clj-kondo
naomarik 2021-03-17T03:20:58.026300Z

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

❤️ 1
Alex Whitt 2021-03-17T14:59:13.027800Z

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?

borkdude 2021-03-17T15:00:17.028Z

that config should work though

borkdude 2021-03-17T15:00:33.028300Z

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

Alex Whitt 2021-03-17T15:00:53.028500Z

I'm on clj-kondo v2021.02.13

borkdude 2021-03-17T15:02:28.028700Z

I'll try

Alex Whitt 2021-03-17T15:03:44.028900Z

Much obliged, thank you

Alex Whitt 2021-03-17T15:04:40.029500Z

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

borkdude 2021-03-17T15:05:42.030100Z

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

Alex Whitt 2021-03-17T15:07:12.030700Z

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

Alex Whitt 2021-03-17T15:11:51.031300Z

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

borkdude 2021-03-17T15:12:49.031500Z

Let me try...

borkdude 2021-03-17T15:13:48.031800Z

Looks like it works correctly here:

borkdude 2021-03-17T15:14:33.032500Z

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

borkdude 2021-03-17T15:14:36.032700Z

with your new config

Alex Whitt 2021-03-17T15:16:22.033500Z

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

Alex Whitt 2021-03-17T15:17:54.034Z

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

borkdude 2021-03-17T15:18:19.034400Z

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

borkdude 2021-03-17T15:18:52.034800Z

that will lint your deps

borkdude 2021-03-17T15:19:02.035100Z

and put the var info in your local cache

Alex Whitt 2021-03-17T15:19:20.035800Z

🙏

borkdude 2021-03-17T15:19:22.036Z

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 Whitt 2021-03-17T15:19:25.036100Z

Thank you!

Alex Whitt 2021-03-17T15:19:43.036500Z

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

borkdude 2021-03-17T15:19:49.036700Z

yes

Alex Whitt 2021-03-17T15:19:59.037Z

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

borkdude 2021-03-17T15:20:25.037400Z

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

borkdude 2021-03-17T15:20:56.037600Z

if you want to sync

ericdallo 2021-03-17T16:03:31.038300Z

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

ericdallo 2021-03-17T16:04:01.038400Z

For a code like:

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

ericdallo 2021-03-17T16:04:10.038600Z

this already works with deftest

ericdallo 2021-03-17T16:04:32.038800Z

Not sure this is related with defflow being a custom hook

ericdallo 2021-03-17T16:04:52.039Z

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

ericdallo 2021-03-17T16:05:48.039200Z

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

borkdude 2021-03-17T16:08:39.039800Z

yeah, we can add that. issue + PR welcome

👍 1
borkdude 2021-03-17T16:08:53.040100Z

it's pretty much ad hoc I think

borkdude 2021-03-17T16:09:05.040300Z

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

ericdallo 2021-03-17T16:10:44.040500Z

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

borkdude 2021-03-17T16:11:42.040700Z

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

ericdallo 2021-03-17T16:12:32.040900Z

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

ericdallo 2021-03-17T16:12:57.041100Z

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

ericdallo 2021-03-17T16:14:48.041300Z

https://github.com/clj-kondo/clj-kondo/issues/1216

ericdallo 2021-03-17T18:28:15.041600Z

@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

borkdude 2021-03-17T18:30:41.042300Z

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

ericdallo 2021-03-17T18:30:50.042500Z

Sure!