babashka/test/babashka/scripts/check_var_names.bb
Bob 3d0befb52b
update some SciVar names (metadata-wise) to align with babashka name (#1236)
* update SciVar names to align with the symbols in the namespace maps

* make test using a bb script more consistent with others

* update changelog
2022-04-07 14:02:06 +02:00

14 lines
869 B
Clojure

(require '[clojure.string :as str])
(let [ns-maps (->> (all-ns)
(map (fn [nmspc] [(ns-name nmspc) (ns-publics nmspc)]))
(into {})) ; a map of { ns-name {symbol var, ...}}
ns-maps (update ns-maps 'user #(dissoc % '*input*))] ; *input* is a special case that we'll skip over
(->>
(for [[ns-nm _] ns-maps
[sym vr] (ns-maps ns-nm)
:let [{var-meta-ns :ns, var-meta-name :name} (meta vr)
var-meta-ns-name (some-> var-meta-ns ns-name)]]
; build a seq of maps containing the ns/symbol from the ns and the ns/symbol from the var's metadata
{:actual-ns ns-nm :actual-ns-symbol sym :var-meta-ns var-meta-ns-name :var-meta-name var-meta-name})
; and remove the matches
(remove #(and (= (:actual-ns %) (:var-meta-ns %)) (= (:actual-ns-symbol %) (:var-meta-name %))))))