Fork me on GitHub
#clj-kondo
<
2020-06-28
>
souenzzo14:06:49

Hello I'm developing a inspector/plugin tool Does kondo has a function like this:

(kondo/resolve {:sym 'clojure.core/+ 
                :classpath "...."})
=> [{:file "clojure/core.clj"
     :line 123
     :jar "org/clojure/clojure.jar"
     ....}]

borkdude15:06:37

@souenzzo You could maybe utilize the analysis output for this:

clj-kondo --lint - --config '{:output {:analysis true :format :edn}}' <<< '(defn foo []) (foo)'
{:analysis {:var-definitions [{:filename "<stdin>", :row 1, :col 1, :ns user, :name foo, :fixed-arities #{0}}], :var-usages [{:name defn, :filename "<stdin>", :from user, :macro true, :col 2, :arity 2, :varargs-min-arity 2, :row 1, :to clojure.core} {:filename "<stdin>", :row 1, :col 16, :from user, :to user, :name foo, :fixed-arities #{0}, :arity 0}]}}

souenzzo17:06:26

Most of kondo output is just about current project. I need also info about dependencies

borkdude19:06:30

Then you'll need to lint also the dependencies

souenzzo20:06:06

Wow I can

(kondo/run!
  {:lint (string/split "....my giant classpath...."
                       #":")})
Nice. Thanks

borkdude20:06:56

You don't have to split the classpath, clj-kondo understands classpaths

borkdude20:06:13

so just {:lint [the-classpath]}

borkdude21:06:17

if you use this option: https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#output-canonical-file-paths clj-kondo will also output the .jar file under :filename

👍 3
borkdude15:06:07

In the above example it outputs the definition of user/foo in the file <stdin> and the usage of user/foo also in the file <stdin>