Created
November 4, 2019 17:09
-
-
Save souenzzo/5a15947ce3449a2a084d7b81d9cb1efd to your computer and use it in GitHub Desktop.
!!!! QUCK'n'DIRTY SOLUTION !!!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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