Fork me on GitHub
#clj-kondo
<
2024-04-27
>
craftybones08:04:07

Will this bit of code get me all invocations of bar in the function foo ?

(->> results
     :analysis 
     :var-usages 
     (filter #(= 'bar (:name %))) 
     (filter #(= 'foo (:from-var %))))

craftybones08:04:01

Ignoring namespaces for now

borkdude09:04:59

I think so yes

craftybones10:04:12

Is analysis not included when using clj-kondo as a pod on babashka?

borkdude10:04:56

Sure it is but you have to call it with analysis enabled

borkdude10:04:06

you can see for example here where it is used in quickdoc: https://github.com/borkdude/quickdoc/blob/main/src/quickdoc/api.cljc it doesn't matter here if you use clj-kondo on the JVM or via the pod, same results

craftybones10:04:29

Ah got it, I didn’t have it inside a :config

borkdude10:04:46

yeah, this also confuses me ;)

sheluchin18:04:29

Is there any feasible path to adding library name and coordinates to var-usages?

borkdude18:04:58

clj-kondo doesn't know them, only the classpath that is provided

borkdude18:04:15

you'd have to reverse engineer which files came from which dependency

phill22:04:46

Which I imagine would be a byproduct of a very useful step - checking for things provided by multiple sources/jars - a grievous pickle that I last noticed in connection with a GraphQL-related library that pulled in 2 ANTLR jars with nominally overlapping contents...

sheluchin22:04:30

@U0HG4EHMH could you elaborate please?

phill22:04:50

In the sense that if you have sufficient information to declare that a Java class is ambiguous (and cite the libraries that contribute it) you also have sufficient information to cite the library that contributed any particular namespace

sheluchin22:04:23

@U0HG4EHMH not totally sure I understand what you mean. Here's an example I'm dealing with:

ns          | cljs.core
name        | defn
repos       | ['athos/reading-clojurescript', 'clojure/clojurescript']
so what we have here is cljs.core/defn, which is defined in two libraries. There are obviously going to be a ton of usages for this, but I don't see a clear way to disambiguate which of the definitions a usage points at. Maybe looking at deps.edn/project.clj might help, but it's still not 100%.