Fork me on GitHub
#clj-kondo
<
2021-05-27
>
borkdude17:05:45

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

emak11:05:46

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

👍 3
borkdude18:05:29

There we have the first one @thiagokokada :)

kokada18:05:02

That was fast 😆

Felipe Marques20:05:51

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 Marques20:05:45

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

Felipe Marques20:05:56

Nervermind! 😅

Joshua Suskalo21:05:09

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

borkdude21:05:43

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

borkdude21:05:09

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

Joshua Suskalo21:05:43

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.

blak3mill3r21:05:08

it is all defnav

borkdude21:05:10

can you explain what you mean by the latter?

borkdude21:05:22

you can solve that using :lint-as

blak3mill3r21:05:44

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

blak3mill3r21:05:10

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

borkdude21:05:56

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

borkdude21:05:13

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

borkdude21:05:21

and so you will get less precise linting

blak3mill3r21:05:26

got it, that makes sense

Joshua Suskalo21:05:38

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

borkdude21:05:57

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

Joshua Suskalo21:05:24

So that'd just be by running

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

borkdude21:05:39

correct. use --parallel too for higher speed

borkdude21:05:52

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

borkdude21:05:28

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

borkdude21:05:31

so did it work out now @suskeyhose?

Joshua Suskalo21:05:34

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.

borkdude21:05:51

did it say something about skipping already linted jars?

Joshua Suskalo21:05:05

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.

Joshua Suskalo21:05:14

just not the defnav ones

borkdude21:05:01

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

Joshua Suskalo21:05:51

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

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

Joshua Suskalo21:05:05

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

borkdude21:05:22

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

borkdude21:05:15

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

Joshua Suskalo21:05:03

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

Joshua Suskalo21:05:50

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.

blak3mill3r21:05:55

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

blak3mill3r21:05:13

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

borkdude21:05:46

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

Joshua Suskalo21:05:59

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

borkdude21:05:26

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

Joshua Suskalo21:05:52

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

Joshua Suskalo21:05:33

I forgot to remove the .cpcache, but whatever

borkdude21:05:26

@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.

borkdude21:05:38

so it probably needs another lint-as for this

borkdude21:05:53

defmacroalias defnav macros/defnav

Joshua Suskalo21:05:58

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

borkdude21:05:25

yep, that's it:

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

Joshua Suskalo21:05:37

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

borkdude22:05:06

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

blak3mill3r22:05:39

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

Joshua Suskalo22:05:44

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