clj-kondo

https://github.com/clj-kondo/clj-kondo
borkdude 2021-05-27T17:55:45.070Z

I deleted borkdude/babashka and borkdude/clj-kondo on Dockerhub now. Let's see how many questions I will get and how many CIs will break... tl;dr: use babashka/babashka and cljkondo/clj-kondo

emak 2021-05-31T11:02:46.109700Z

☝️ it broke the GH actions in our repo :) BTW thanks for this awesome tool!

👍 1
borkdude 2021-05-27T18:24:29.070300Z

There we have the first one @thiagokokada :)

kokada 2021-05-27T18:26:02.070800Z

That was fast 😆

Felipe Marques 2021-05-27T20:39:51.072600Z

Hi, everyone, I'm getting a weird error on clj-kondo for a file:

test/integration/enrollment_view/primary_inclusion_flow.clj:1:1: error: Unresolved symbol:
After running:
clj-kondo --cache false --lint test/integration/enrollment_view/primary_inclusion_flow.clj
I even changed the content of the file to a file that is not failing, but I keep keeting this error. Did anyone have a similar problem?

Felipe Marques 2021-05-27T20:45:45.072800Z

It was the UTF-8 BOM character 😅 Solved by changing the encoding.

Felipe Marques 2021-05-27T20:45:56.073200Z

Nervermind! 😅

2021-05-27T21:10:09.074500Z

Is there any way for me to configure the :use linter to not complain about a particular ns? In this case, we like including all the specter vars with refer-all, but if we manually use (:require [com.rpl.specter :refer :all]) it says unresolved symbol on all the uses

borkdude 2021-05-27T21:12:43.075Z

@suskeyhose these unresolved symbols should go away when linting the used namespace as well

borkdude 2021-05-27T21:13:09.075600Z

if specter uses standard clojure to define those var and not some defcustom macro

2021-05-27T21:13:43.076200Z

Ah, I see. Then I wonder why it has unresolved symbol if we put the ns in the require block but not in the use block.

blak3mill3r 2021-05-27T21:15:08.077Z

it is all defnav

borkdude 2021-05-27T21:15:10.077200Z

can you explain what you mean by the latter?

blak3mill3r 2021-05-27T21:15:13.077300Z

in specter

borkdude 2021-05-27T21:15:22.077700Z

you can solve that using :lint-as

blak3mill3r 2021-05-27T21:15:44.078100Z

if we put it in (:use [com.rpl.specter]) then there are no complaints about unresolved symbols from specter

blak3mill3r 2021-05-27T21:16:10.078700Z

but with (:require [com.rpl.specter :refer :all]) kondo cannot resolve the symbols from specter

borkdude 2021-05-27T21:16:56.079400Z

ah I see what the problem is. when using :refer :all clj-kondo will go out to the cache and see if this info is already there, to give more accurate linting

borkdude 2021-05-27T21:17:13.079900Z

but if specter using defnav then clj-kondo hasn't saved these vars to the cache

borkdude 2021-05-27T21:17:21.080300Z

and so you will get less precise linting

blak3mill3r 2021-05-27T21:17:26.080600Z

got it, that makes sense

2021-05-27T21:17:38.080900Z

I tried using lint-as and it didn't appear to fix it, but maybe I need to do something to run it without the cache

borkdude 2021-05-27T21:17:57.081300Z

@suskeyhose you need to re-lint specter after the config change

2021-05-27T21:20:24.082Z

So that'd just be by running

clj-kondo --dependencies --lint "$(clojure -Spath)"
right?

borkdude 2021-05-27T21:20:39.082300Z

correct. use --parallel too for higher speed

2021-05-27T21:21:14.082500Z

okay, cool

borkdude 2021-05-27T21:23:52.083300Z

if specter would package a clj-kondo config in the jar, then you would also get a copy of that in your .clj-kondo and this way of linting would tell you how to activate that

borkdude 2021-05-27T21:24:28.083700Z

Perhaps you could suggest this to the specter author, if you find a config that works well: https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#exporting-and-importing-configuration

borkdude 2021-05-27T21:31:31.084200Z

so did it work out now @suskeyhose?

2021-05-27T21:32:34.085Z

No, and I'm not quite sure why. I set it to lint the defnav calls as defn, (like this https://github.com/redplanetlabs/specter/blob/master/src/clj/com/rpl/specter.cljc#L715-L723), but it's still unable to resolve those symbols.

borkdude 2021-05-27T21:32:51.085600Z

did it say something about skipping already linted jars?

2021-05-27T21:33:05.086Z

I was able to validate that it refreshed the cache because some of the symbols it hadn't recognized before it did recognize this time.

2021-05-27T21:33:14.086200Z

just not the defnav ones

borkdude 2021-05-27T21:34:01.086800Z

can you post your config? also to be sure, just rm -rf .clj-kondo/.cache and try again

2021-05-27T21:34:51.087600Z

I'll try removing the cache and retrying. The whole config is just

{:lint-as {com.rpl.specter/defnav clojure.core/defn}}

2021-05-27T21:35:05.087900Z

This is the first time we've used a linter on this project, trying to adopt it.

borkdude 2021-05-27T21:36:22.088300Z

clj-kondo just has a hard time with :refer :all and custom def macros

borkdude 2021-05-27T21:37:15.088900Z

it also suggest trying not to use :refer :all (for this reason, but also for other reasons, just as a general style recommendation)

2021-05-27T21:38:03.089200Z

oh boy, now it doesn't work in the use block either 😂

2021-05-27T21:38:50.090100Z

Yeah, this is just unfortunate. In any case I'd still be curious if we could customize the :use linter to not complain for particular namespaces.

blak3mill3r 2021-05-27T21:38:55.090300Z

we avoid :refer :all like the plague, with the one exception of specter

blak3mill3r 2021-05-27T21:39:13.090700Z

because that's a lot of short & common symbols that we do not want to prefix with s/

borkdude 2021-05-27T21:39:46.091200Z

it would be good to have a repro of this, because I think it should work

2021-05-27T21:39:59.091500Z

I'll see if I can make a tiny thing that reproduces the error.

borkdude 2021-05-27T21:44:26.092Z

I will take a look tomorrow and will call it a day, it's getting close to midnight here.

blak3mill3r 2021-05-27T21:44:35.092200Z

many thanks @borkdude

2021-05-27T21:52:52.092800Z

Oh that's funny, it thinks it's C++

2021-05-27T21:53:33.093Z

I forgot to remove the .cpcache, but whatever

borkdude 2021-05-27T21:57:26.093900Z

@suskeyhose I think I see the issue. The defnav macro, in .clj at least, is a locally defined using another macro. In cljs it works differently.

borkdude 2021-05-27T21:57:38.094200Z

so it probably needs another lint-as for this

borkdude 2021-05-27T21:57:53.094600Z

defmacroalias defnav macros/defnav

2021-05-27T21:57:58.094800Z

Right, but if I have it lint-as defn, wouldn't that remove the issue? It seems odd that I'd have to change how defmacroalias is linted too

borkdude 2021-05-27T21:59:25.095100Z

yep, that's it:

{:lint-as {com.rpl.specter/defnav clojure.core/defn
           com.rpl.specter/defmacroalias clojure.core/def}}
this works

2021-05-27T21:59:37.095400Z

Okay, cool. Well I'll go for that. Thanks!

borkdude 2021-05-27T22:01:06.095800Z

Feel free to contribute the config here: https://github.com/clj-kondo/config once you have it all working

borkdude 2021-05-27T22:01:28.096300Z

Or perhaps in the specter repo itself: https://github.com/clj-kondo/clj-kondo/blob/master/doc/config.md#exporting-and-importing-configuration

blak3mill3r 2021-05-27T22:02:39.097400Z

Excellent! I have a feeling that a lot of specter users do refer all the symbols... contributing this kondo config to specter might make sense

2021-05-27T22:04:44.097900Z

Sounds good, I'll look at making a PR in specter