Fork me on GitHub

we have a habit of using macros to generate def's in our libraries


recently clj-kondo started reporting all of these as unresolved-vars


according to this clj-kondo should accept them if you import them from another namespace, but that seems to no longer be true


you can solve this either with :lint-as { clojure.core/def} or just disabling that linter. the point of that linter is when you use vars from another namespace that don't exist, you will get a warning.


that's only true if there are no other vars in that namespace


you can also :exclude some namespaces in the linter config


I'm not entirely sure about the empty namespace: it's complaining about unresolved-vars from a namespace that contains just an s/fdef and the macro that generates all these vars


I know I can tell clj-kondo to ignore them, but it's a very common pattern in our codebase, and so keeping the ignore list up to date will be a lot of work


can you show me an example of such a macro?


I've sent a gist in a dm


if someone else reads these messages: I've sorted out the problem using a hook that replaces the macro calls with declare/def statements


since these calls are in libraries in my case I also had to reindex the cache with clj-kondo --lint "$(lein classpath)"


yep, that's the way to do it, cool that you made it work


Just wanted to mention that this is flagged as "missing :mvn/version, :git/url, or :local/root" although it is legal now in the latest t.d.a:

io.github.cognitect-labs/test-runner {:git/tag "v0.3.1" :git/sha "705ad25"}


ah is it. then it shall be updated in kondo.


what is the rule here, if there is a git/sha, what rule should the library symbol have in order for it to be resolved to github/gitlab etc?

Joshua Suskalo20:07:23

it has to conform to ^(com|io)\.(github|gitlab)\..*$ at the moment I think


☝️:skin-tone-2: Yup, sounds right. And if it's that format, :git/url can be omitted and the you should have :git/tag AND :git/sha.

Joshua Suskalo21:07:10

need to check the actual tools deps code though, the guide on only mentions github, not gitlab


if you only have git/tag will the tool then insert the SHA or...? tags can be a bit volatile


(I think there's also some wiggle room in t.d.a right now because I put {:tag ".." :sha ".."} in one deps.edn file and it was perfectly happy with it, to my surprise)

Joshua Suskalo21:07:15

If you have a tag you can have a prefix sha, but if you have no tag you need a full sha


Having only :git/tag is not allowed I think.

Joshua Suskalo21:07:28

but you always need a :git/sha key.


git/tag is more or less for humans, let's say?

Joshua Suskalo21:07:45

Yeah, the only exception to needing the :git/sha with the tag is when installing a tool with -Ttools


(or just :sha in the old format)


is :sha still accepted?


I will copy paste this into an issue


for now you can use #_:clj-kondo/ignore to ignore false positives

Joshua Suskalo21:07:06

Like I said somewhere else, I think I want to write a tool for use with -T which allows you to specify only a tag and then it'd use rewrite-clj to add the dep to your deps.edn file with a prefix sha.

❤️ 2

yeah, that's pretty easy. can just be a small bb script even

Joshua Suskalo21:07:30

Yeah, a bb script would be a good way to package it to run elsewhere, but that is kinda what -T is for on this. Would probably just make it compatible with bb so that it could be run that way if a user wants.


oh you mean that script could be installed using -T, yeah, that's meta ;)


Thanks for letting me know.


If anyone wants to work on this, feel free. I have to write a talk this weekend so I probably won't get to it by then :)

Joshua Suskalo21:07:37

I'd volunteer if my weekend weren't already full


no worries, it'll be done eventually


Logic around what can be in git coords: -- :tag and :sha are supported but :git/tag and :git/sha are "preferred" it seems (and you can't have both the qualified and unqualified versions).


(and I doubt this is urgent for anyone b/c very few folks are going to be a) running the very latest t.d.a and b) using the new, shorter git coords 🙂 )

👍 2

makes sense