Skip to content

Commit

Permalink
Fix false positive for clojure.spec.alpha/every
Browse files Browse the repository at this point in the history
Fixes #435
  • Loading branch information
vemv committed Jun 17, 2022
1 parent 4b84b11 commit 177080e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 2 deletions.
21 changes: 21 additions & 0 deletions cases/testcases/constant_test/spec_every/green.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
(ns testcases.constant-test.spec-every.green
(:require
[clojure.spec.gen.alpha :as gen]
[clojure.test :refer [are deftest is join-fixtures testing use-fixtures]]
[clojure.spec.alpha :as spec]))

;; https://github.com/jonase/eastwood/issues/435
(spec/def ::some-spec (spec/map-of
(spec/spec string?
:gen (fn [] (gen/fmap
#(apply str %)
(gen/vector
gen/char-alpha
5 20))))
(spec/coll-of
(spec/tuple ::source ::sub-type)
:into #{}
:min-count 2
:gen-max 7)
:min-count 2
:gen-max 8))
7 changes: 7 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Changes from 1.2.3 to

#### Bugfixes

* Fix false positive for `clojure.spec.alpha/every`.
* Closes https://github.com/jonase/eastwood/issues/435

## Changes from 1.2.2 to 1.2.3

#### Bugfixes
Expand Down
5 changes: 4 additions & 1 deletion resource/eastwood/config/clojure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@
(disable-warning
{:linter :constant-test
:for-macro 'clojure.core/or
:if-inside-macroexpansion-of #{'clojure.spec/coll-of 'clojure.spec.alpha/coll-of}
:if-inside-macroexpansion-of #{'clojure.spec/coll-of
'clojure.spec.alpha/coll-of
'clojure.spec/every
'clojure.spec.alpha/every}
:within-depth 8
:reason "clojure.spec's `coll-of` can contain `clojure.core/or` invocations with only one argument."})

Expand Down
11 changes: 10 additions & 1 deletion test/eastwood/lint_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,16 @@ relative to a specific macroexpansion"
;; Suggested an improvement upstream here:
;; https://ask.clojure.org/index.php/10712/minor-performance-improvement-initial-values-known-compile
#{'testcases.constant-test.some-thread-first.green} {:some-warnings false}
#{'testcases.constant-test.some-thread-last.green} {:some-warnings false})))
#{'testcases.constant-test.some-thread-last.green} {:some-warnings false}))

(testing "https://github.com/jonase/eastwood/issues/435"
(are [input expected] (testing input
(is (= (assoc expected :some-errors false)
(-> sut/default-opts
(assoc :namespaces input)
(sut/eastwood))))
true)
#{'testcases.constant-test.spec-every.green} {:some-warnings false})))

(deftest unused-fn-args-test
(testing "fn args within defmulti, see https://github.com/jonase/eastwood/issues/1"
Expand Down

0 comments on commit 177080e

Please sign in to comment.