Skip to content

Commit

Permalink
Make the :wrong-tag linter omittable (#372)
Browse files Browse the repository at this point in the history
Supports the speced.def library.
  • Loading branch information
vemv authored Apr 29, 2021
1 parent d5e63fa commit 3ad7400
Show file tree
Hide file tree
Showing 12 changed files with 422 additions and 145 deletions.
46 changes: 43 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- run:
name: Fetch dependencies
command: |
lein deps
lein with-profile +test,+test-3rd-party-deps, deps
- save_cache:
paths:
Expand All @@ -60,8 +60,40 @@ jobs:
command: git clean -fdx

- run:
name: Run test suite
name: Run normal test suite
command: lein with-profile -user,-dev,+test,+warn-on-reflection,+<< parameters.clojure-version >> do clean, test

test_third_party_deps:
parameters:
executor:
type: executor
clojure-version:
type: string
executor: << parameters.executor >>
steps:
- checkout

- restore_cache:
keys:
- v1-dependencies-{{ checksum "project.clj" }}

- run:
name: Fetch dependencies
command: |
lein with-profile +test,+test-3rd-party-deps, deps
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "project.clj" }}

- run:
name: Prevent any form of caching, for the next step
command: git clean -fdx

- run:
name: Run test suite that exercises 3rd-party libs
command: lein with-profile -user,-dev,+test,+warn-on-reflection,+test-3rd-party-deps,+<< parameters.clojure-version >> do clean, test

workflows:
default:
Expand All @@ -70,4 +102,12 @@ workflows:
matrix:
parameters:
executor: [openjdk8, openjdk11]
clojure-version: ["1.7", "1.8", "1.9", "1.10.1", "1.10.2"]
clojure-version: ["1.7", "1.8", "1.9", "1.10.1", "1.10.2", "1.10.3"]
# the `test_third_party_deps` profile uses a separate matrix because the contained libs (especially the ones that use clojure.spec)
# don't target older versions.
- test_third_party_deps:
matrix:
parameters:
executor: [openjdk8, openjdk11]
# Run just the latest version. This saves resources trusts that the main test suite already exercises clojure compat sufficiently:
clojure-version: ["1.10.3"]
7 changes: 7 additions & 0 deletions cases/testcases/wrong_tag_example.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(ns testcases.wrong-tag-example)

(defmacro the-macro [n x]
`(defn ~n ~(with-meta [] {:tag pos?})
~x))

(the-macro foo 42)
5 changes: 5 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Changes from 0.4.0 to

#### New

* Now the `:wrong-tag` linter can also be configured via the [`disable-warning`](https://github.com/jonase/eastwood#eastwood-config-files) mechanism.
* Related: the `disable-warnings` that Eastwood ships by default now prevent false positives against the [speced.def](https://github.com/nedap/speced.def) lib.

#### Bugfixes

* Vanilla `defn`s having `:test` metadata don't result in false positives for the `:bad-arglists` linter anymore.
Expand Down
11 changes: 9 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,23 @@
[jafingerhut/dolly "0.1.0"]]}
:eastwood-plugin {:source-paths [~plugin-source-path]}
:warn-on-reflection {:global-vars {*warn-on-reflection* true}}
:test {:dependencies [[commons-io "2.4" #_"Needed for issue-173-test"]]
:test {:dependencies
;; NOTE: please don't add non-essential 3rd-party deps here.
;; It is desirable to rest assured that the test suite does not depend on a third-party lib.
;; If you wish to exercise compatibility against a 3rd-party lib, use the `:test-3rd-party-deps` profile instead.
[[commons-io "2.4" #_"Needed for issue-173-test"]]
:resource-paths ["test-resources"
;; if wanting the `cases` to be available during development / the default profile,
;; please simply add `with-profile +test` to your CLI invocation.
"cases"]}
:test-3rd-party-deps {:test-paths ^:replace ["test-third-party-deps"]
:dependencies [[com.nedap.staffing-solutions/speced.def "2.0.0"]]}
:1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}
:1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]}
:1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]}
:1.10.1 {:dependencies [[org.clojure/clojure "1.10.1"]]}
:1.10.2 {:dependencies [[org.clojure/clojure "1.10.2"]]}}
:1.10.2 {:dependencies [[org.clojure/clojure "1.10.2"]]}
:1.10.3 {:dependencies [[org.clojure/clojure "1.10.3"]]}}
:aliases {"test-all" ["with-profile"
~(->> ["1.7" "1.8" "1.9" "1.10"]
(map (partial str "-user,-dev,+test,+warn-on-reflection,+"))
Expand Down
23 changes: 21 additions & 2 deletions resource/eastwood/config/third-party-libs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@
([] [a b])]

[[hiccup.test.def/three-forms-extra]
([] [a] [a b])]
)]
([] [a] [a b])])]
;; hiccup defelem's allow an optional first map argument
(let [defelem-modified-arglists (concat arglist
(map #(vec (cons 'attr-map? %))
Expand Down Expand Up @@ -310,3 +309,23 @@
:if-inside-macroexpansion-of #{'slingshot.slingshot/try+}
:within-depth 15
:reason "slingshot.slingshot/try+ generates an (and ...) with one or more arguments. Suppress the 'and called with 1 args' warning."})

(disable-warning
{:linter :constant-test
:for-macro 'clojure.core/if
:if-inside-macroexpansion-of '#{nedap.speced.def/defn
nedap.speced.def/defprotocol
nedap.speced.def/let
nedap.speced.def/letfn
nedap.speced.def/fn}
:within-depth 13
:reason "The emitted code emits an (if (class? x) ...) where x may be a class or a protocol. The result cannot be known at compile-time (especially as classes and protocols can be defined in runtime)."})

(disable-warning
{:linter :wrong-tag
:if-inside-macroexpansion-of '#{nedap.speced.def/defn
nedap.speced.def/defprotocol
nedap.speced.def/let
nedap.speced.def/letfn
nedap.speced.def/fn}
:reason "The speced.def library uses an extended meaning for tag syntax."})
Loading

0 comments on commit 3ad7400

Please sign in to comment.