!!!! QUCK'n'DIRTY SOLUTION !!!!
(let [{:keys [namespace-usages]} (:analysis (kondo/run! {:lint ["src/main" | |
"src/old"] | |
:config {:output {:analysis true}}})) | |
url->splited-path #(into [] | |
(comp (map (memfn getFileName)) | |
(map str) | |
(take-while (complement string/blank?))) | |
(iterate (fn [x] (when x (.getParent x))) | |
(Paths/get (new URI (-> (str %) | |
(string/replace #"^jar\:" | |
"") | |
(string/replace #"\!.+$" | |
"")))))) | |
find-urls #(let [base (-> (namespace-munge %) | |
(string/replace #"\." "/"))] | |
(for [suffix ["clj" "cljc" "cljs"] | |
:let [url (io/resource (str base "." suffix))] | |
:when url | |
:let [path (url->splited-path url) | |
[jar version name & ns] path | |
ns (drop 1 (drop-while (complement #{"repository"}) | |
(reverse ns)))] | |
:when (or (seq ns) | |
(prn [:warn url]))] | |
(symbol (string/join "." ns) name))) | |
own (->> namespace-usages | |
(map :from) | |
set) | |
{:keys [dependencies]}(rest (edn/read-string (slurp "project.clj"))) | |
deps-from-project (into (sorted-set) | |
(comp (map first) | |
(map (fn [x] | |
(if (simple-symbol? x) | |
(symbol (name x) (name x)) | |
x)))) | |
dependencies) | |
deps-from-requires (->> namespace-usages | |
(map :to) | |
(remove own) | |
set | |
(mapcat find-urls) | |
(into (sorted-set)))] | |
(remove deps-from-requires deps-from-project)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment