clj-kondo

https://github.com/clj-kondo/clj-kondo
souenzzo 2020-06-28T14:23:49.072200Z

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"
     ....}]

borkdude 2020-06-28T15:02:37.073400Z

@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}]}}

borkdude 2020-06-28T15:03:07.074Z

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>

borkdude 2020-06-28T15:03:37.074300Z

Other work in this area is https://github.com/didibus/anakondo

souenzzo 2020-06-28T17:35:26.074600Z

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

borkdude 2020-06-28T19:02:30.074800Z

Then you'll need to lint also the dependencies

souenzzo 2020-06-28T20:56:06.075Z

Wow I can

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

borkdude 2020-06-28T20:58:56.075200Z

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

borkdude 2020-06-28T20:59:13.075400Z

so just {:lint [the-classpath]}

borkdude 2020-06-28T21:00:17.075600Z

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

👍 1