Skip to content

Commit 8a0042a

Browse files
committed
Fix libspec-allowlist
Fixes #363
1 parent 6c599d2 commit 8a0042a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/refactor_nrepl/ns/libspec_allowlist.clj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[clojure.java.io :as io]
44
[refactor-nrepl.config :as config])
55
(:import
6+
(clojure.lang IFn)
67
(java.util.regex Pattern)))
78

89
(defn- libspec-allowlist* []
@@ -20,7 +21,7 @@
2021
entry)))
2122
(into (:libspec-whitelist config/*config*)))))
2223

23-
(def ^:private ^:dynamic *libspec-allowlist* nil)
24+
(def ^:private ^:dynamic ^IFn *libspec-allowlist* nil)
2425

2526
(defn with-memoized-libspec-allowlist* [f]
2627
(binding [*libspec-allowlist* (memoize libspec-allowlist*)]
@@ -32,7 +33,7 @@
3233
3334
Uses a memoized version if available."
3435
[]
35-
(or *libspec-allowlist*
36+
(or (some-> *libspec-allowlist* .invoke)
3637
(libspec-allowlist*)))
3738

3839
(defmacro with-memoized-libspec-allowlist

test/refactor_nrepl/ns/libspec_allowlist_test.clj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[refactor-nrepl.ns.libspec-allowlist :as sut]
55
[refactor-nrepl.ns.prune-dependencies :as prune-dependencies]))
66

7-
(deftest libspec-allowlist
7+
(deftest libspec-allowlist-test
88
(testing "Takes into account refactor-nrepls own config, and .clj-kondo/config files alike,
99
merging their results"
1010
(is (= [;; From refactor-nrepl's default config:
@@ -29,4 +29,9 @@ effecively parsing its config into well-formed regexes"
2929
'sample.unused.namespaceB false
3030
'more.unused.namespaces true
3131
'more.unused.namespacessss true
32-
'more.unused.namespac false))))
32+
'more.unused.namespac false))
33+
34+
(testing "Always returns a sequence, memoized or not"
35+
(is (seq (sut/with-memoized-libspec-allowlist
36+
(sut/libspec-allowlist))))
37+
(is (seq (sut/libspec-allowlist))))))

0 commit comments

Comments
 (0)