Skip to content

Commit d867dc9

Browse files
committed
Add additional integrations tests for libraries that use splint
1 parent 5e819b6 commit d867dc9

14 files changed

+592
-129
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This changelog is loose. Versions are not semantic, they are incremental. Splint
1818
- New config option for `lint/fn-wrapper`: `:names-to-skip`. Given that many macros require wrapping, skipping them (or any other calls) can be configured with `:names-to-skip`, which takes a vector of simple symbols to skip during analysis. For example, `lint/fn-wrapper {:names-to-skip [inspect]}` will not trigger on `(add-tap (fn [x] (morse/inspect)))`.
1919
- New config option for `style/redundant-nested-call`: `:fn-names`. By default, `style/redundant-nested-call` only checks a handful of `clojure.core` vars. To check against custom functions, add them to the config with `style/redundant-nested-call {:fn-names [foo bar]}`.
2020
- Rules support `:config-coercer`, a one-arg function that takes the final result of a rules' processed config and should return it. Allows for rules to define custom ways of handling config data before it's used (such as unifying args). See `lint/catch-throwable` for an example.
21+
- DEV ONLY: add roughly 10 new integrations tests for github repos that already rely on Splint.
2122

2223
### Changed
2324

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
; This Source Code Form is subject to the terms of the Mozilla Public
2+
; License, v. 2.0. If a copy of the MPL was not distributed with this
3+
; file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
(ns noahtheduke.splint.integrations.clj-auth-test
6+
{:integration true}
7+
(:require
8+
[clojure.tools.gitlibs :as gl]
9+
[lazytest.core :refer [defdescribe expect it]]
10+
[lazytest.extensions.matcher-combinators :refer [match?]]
11+
[matcher-combinators.matchers :as m]
12+
[noahtheduke.splint.clojure-ext.core :refer [update-vals*]]
13+
[noahtheduke.splint.integrations.helpers :refer [usefully-enabled-config]]
14+
[noahtheduke.splint.runner :refer [run-impl]]))
15+
16+
(set! *warn-on-reflection* true)
17+
18+
(def clj-auth-diagnostics
19+
'{lint/defmethod-names 7
20+
lint/fn-wrapper 1
21+
lint/if-not-both 1
22+
lint/redundant-str-call 3
23+
lint/warn-on-reflection 19
24+
metrics/fn-length 17
25+
performance/dot-equals 27
26+
performance/single-literal-merge 7
27+
style/is-eq-order 6})
28+
29+
(defdescribe clj-auth-test
30+
(let [clj-auth (delay (gl/procure "https://github.com/theophilusx/clj-auth.git"
31+
'theophilusx/clj-auth "4fbbf8222d92227c821c3db34c75a45d6e540185"))
32+
results (delay
33+
(run-impl [{:path @clj-auth}]
34+
{:config-override
35+
(-> (usefully-enabled-config)
36+
(assoc :silent true)
37+
(assoc :parallel false)
38+
(assoc :clojure-version {:major 1 :minor 11}))}))
39+
diagnostics (delay (->> @results
40+
:diagnostics
41+
(group-by :rule-name)
42+
(into (sorted-map))))]
43+
; (user/pprint (dissoc @diagnostics 'lint/warn-on-reflection))
44+
; (user/pprint (into (sorted-map) (update-vals* @diagnostics count)))
45+
(it "has the right diagnostics"
46+
(expect
47+
(match?
48+
(m/equals clj-auth-diagnostics)
49+
(update-vals* @diagnostics count))))
50+
(it "sums correctly"
51+
(expect (= 88 (count (:diagnostics @results)))))
52+
(it "raises no errors"
53+
(expect (nil? (get diagnostics 'splint/error))))
54+
(it "raises no unknown errors"
55+
(expect (nil? (get diagnostics 'splint/unknown-error))))))

test/noahtheduke/splint/integrations/clj_kondo_test.clj

Lines changed: 49 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3,108 +3,87 @@
33
; file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

55
(ns noahtheduke.splint.integrations.clj-kondo-test
6+
{:integration true}
67
(:require
78
[clojure.tools.gitlibs :as gl]
89
[lazytest.core :refer [defdescribe expect it]]
910
[lazytest.extensions.matcher-combinators :refer [match?]]
10-
[noahtheduke.splint.clojure-ext.core :refer [update-vals*]]
1111
[matcher-combinators.matchers :as m]
12-
[noahtheduke.splint.config :refer [default-config]]
12+
[noahtheduke.splint.clojure-ext.core :refer [update-vals*]]
13+
[noahtheduke.splint.integrations.helpers :refer [usefully-enabled-config]]
1314
[noahtheduke.splint.runner :refer [run-impl]]))
1415

1516
(set! *warn-on-reflection* true)
1617

17-
(def all-enabled-config
18-
(-> @default-config
19-
(update-vals* #(assoc % :enabled true))
20-
(assoc-in ['style/set-literal-as-fn :enabled] false)))
21-
2218
(def clj-kondo-diagnostics
2319
'{lint/assoc-fn 1
24-
lint/body-unquote-splicing 2
25-
lint/catch-throwable 4
26-
lint/defmethod-names 63
20+
lint/catch-throwable 6
21+
lint/defmethod-names 6
2722
lint/dot-class-method 2
28-
lint/dot-obj-method 1
2923
lint/fn-wrapper 1
30-
lint/identical-branches 9
31-
lint/if-else-nil 42
32-
lint/if-let-else-nil 2
33-
lint/if-nil-else 2
34-
lint/if-not-both 3
35-
lint/let-if 8
36-
lint/let-when 2
37-
lint/misplaced-type-hint 10
38-
lint/missing-body-in-when 2
24+
lint/identical-branches 2
25+
lint/if-else-nil 1
26+
lint/if-nil-else 1
27+
lint/if-not-both 2
28+
lint/let-if 3
29+
lint/let-when 1
30+
lint/missing-body-in-when 1
3931
lint/no-catch 1
40-
lint/no-op-assignment 2
41-
lint/prefer-require-over-use 4
42-
lint/redundant-str-call 18
43-
lint/thread-macro-one-arg 85
44-
lint/try-splicing 2
45-
lint/underscore-in-namespace 1
46-
lint/warn-on-reflection 229
47-
metrics/fn-length 314
48-
metrics/parameter-count 48
49-
naming/conventional-aliases 14
50-
naming/conversion-functions 2
51-
naming/lisp-case 3
52-
naming/predicate 2
32+
lint/no-op-assignment 3
33+
lint/redundant-str-call 1
34+
lint/thread-macro-one-arg 70
35+
lint/try-splicing 3
36+
lint/warn-on-reflection 112
37+
metrics/fn-length 227
38+
metrics/parameter-count 32
39+
naming/conventional-aliases 5
5340
naming/record-name 1
54-
naming/single-segment-namespace 80
55-
performance/assoc-many 80
56-
performance/avoid-satisfies 2
57-
performance/dot-equals 123
58-
performance/get-keyword 14
59-
performance/single-literal-merge 9
60-
splint/parsing-error 4
61-
style/apply-str 14
62-
style/apply-str-interpose 3
63-
style/cond-else 5
64-
style/def-fn 3
65-
style/eq-false 2
66-
style/eq-true 5
67-
style/eq-zero 2
68-
style/is-eq-order 27
41+
performance/assoc-many 91
42+
performance/dot-equals 83
43+
performance/get-keyword 12
44+
performance/single-literal-merge 2
45+
style/apply-str 1
46+
style/apply-str-interpose 1
47+
style/eq-true 3
6948
style/multiple-arity-order 1
70-
style/neg-checks 7
71-
style/new-object 5
49+
style/neg-checks 1
50+
style/new-object 4
7251
style/not-eq 3
73-
style/not-nil? 12
7452
style/not-some-pred 2
75-
style/plus-one 4
7653
style/pos-checks 1
77-
style/prefer-clj-string 18
78-
style/prefer-condp 3
79-
style/prefer-vary-meta 6
80-
style/prefixed-libspecs 9
81-
style/redundant-let 6
82-
style/redundant-nested-call 6
83-
style/single-key-in 2
84-
style/tostring 4
85-
style/useless-do 6
86-
style/when-do 1
87-
style/when-not-call 15
88-
style/when-not-do 1})
54+
style/prefer-clj-string 5
55+
style/prefer-condp 2
56+
style/prefer-vary-meta 2
57+
style/single-key-in 1
58+
style/tostring 2
59+
style/useless-do 2
60+
style/when-not-call 12})
8961

90-
(defdescribe ^:integration clj-kondo-test
91-
(let [clj-kondo (delay (gl/procure "https://github.com/clj-kondo/clj-kondo.git" 'clj-kondo/clj-kondo "v2023.05.26"))
62+
(defdescribe clj-kondo-test
63+
(let [clj-kondo (delay (gl/procure "https://github.com/clj-kondo/clj-kondo.git"
64+
'clj-kondo/clj-kondo "v2025.06.05"))
9265
results (delay
93-
(run-impl [{:path @clj-kondo}]
66+
(run-impl [{:path (str @clj-kondo "/src")}
67+
{:path (str @clj-kondo "/test")}]
9468
{:config-override
95-
(-> all-enabled-config
69+
(-> (usefully-enabled-config)
9670
(assoc :silent true)
9771
(assoc :parallel false)
9872
#_(assoc :autocorrect true)
9973
(assoc :clojure-version {:major 1 :minor 11}))}))
10074
diagnostics (delay (->> @results
10175
:diagnostics
10276
(group-by :rule-name)))]
103-
; (user/pprint (get @diagnostics 'lint/no-op-assignment))
77+
; (user/pprint (into (sorted-map) (dissoc @diagnostics 'lint/warn-on-reflection 'lint/defmethod-names)))
78+
; (user/pprint (into (sorted-map) (update-vals* @diagnostics count)))
10479
(it "has the right diagnostics"
10580
(expect
10681
(match?
10782
(m/equals clj-kondo-diagnostics)
10883
(update-vals* @diagnostics count))))
10984
(it "sums correctly"
110-
(expect (= 1365 (count (:diagnostics @results)))))))
85+
(expect (= 713 (count (:diagnostics @results)))))
86+
(it "raises no errors"
87+
(expect (nil? (get diagnostics 'splint/error))))
88+
(it "raises no unknown errors"
89+
(expect (nil? (get diagnostics 'splint/unknown-error))))))
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
; This Source Code Form is subject to the terms of the Mozilla Public
2+
; License, v. 2.0. If a copy of the MPL was not distributed with this
3+
; file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
(ns noahtheduke.splint.integrations.dinero-test
6+
{:integration true}
7+
(:require
8+
[clojure.tools.gitlibs :as gl]
9+
[lazytest.core :refer [defdescribe expect it]]
10+
[lazytest.extensions.matcher-combinators :refer [match?]]
11+
[matcher-combinators.matchers :as m]
12+
[noahtheduke.splint.clojure-ext.core :refer [update-vals*]]
13+
[noahtheduke.splint.integrations.helpers :refer [usefully-enabled-config]]
14+
[noahtheduke.splint.runner :refer [run-impl]]))
15+
16+
(set! *warn-on-reflection* true)
17+
18+
(def dinero-diagnostics
19+
'{lint/defmethod-names 25
20+
lint/identical-branches 2
21+
lint/warn-on-reflection 14
22+
metrics/fn-length 8
23+
metrics/parameter-count 5
24+
performance/assoc-many 1
25+
performance/dot-equals 29})
26+
27+
(defdescribe dinero-test
28+
(let [dinero (delay (gl/procure "https://github.com/sernamar/dinero.git" 'com.sernamar/dinero "v0.3.0"))
29+
results (delay
30+
(run-impl [{:path @dinero}]
31+
{:config-override
32+
(-> (usefully-enabled-config)
33+
(assoc :silent true)
34+
(assoc :parallel false)
35+
(assoc :clojure-version {:major 1 :minor 11}))}))
36+
diagnostics (delay (->> @results
37+
:diagnostics
38+
(group-by :rule-name)
39+
(into (sorted-map))))]
40+
; (user/pprint (dissoc @diagnostics 'lint/warn-on-reflection))
41+
; (user/pprint (into (sorted-map) (update-vals* @diagnostics count)))
42+
(it "has the right diagnostics"
43+
(expect
44+
(match?
45+
(m/equals dinero-diagnostics)
46+
(update-vals* @diagnostics count))))
47+
(it "sums correctly"
48+
(expect (= 84 (count (:diagnostics @results)))))
49+
(it "raises no errors"
50+
(expect (nil? (get diagnostics 'splint/error))))
51+
(it "raises no unknown errors"
52+
(expect (nil? (get diagnostics 'splint/unknown-error))))))
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
; This Source Code Form is subject to the terms of the Mozilla Public
2+
; License, v. 2.0. If a copy of the MPL was not distributed with this
3+
; file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
(ns noahtheduke.splint.integrations.env-logger-test
6+
{:integration true}
7+
(:require
8+
[clojure.tools.gitlibs :as gl]
9+
[lazytest.core :refer [defdescribe expect it]]
10+
[lazytest.extensions.matcher-combinators :refer [match?]]
11+
[matcher-combinators.matchers :as m]
12+
[noahtheduke.splint.clojure-ext.core :refer [update-vals*]]
13+
[noahtheduke.splint.integrations.helpers :refer [usefully-enabled-config]]
14+
[noahtheduke.splint.runner :refer [run-impl]]))
15+
16+
(set! *warn-on-reflection* true)
17+
18+
(def env-logger-diagnostics
19+
'{lint/warn-on-reflection 15
20+
metrics/fn-length 40
21+
performance/assoc-many 1
22+
performance/dot-equals 30
23+
performance/single-literal-merge 9
24+
style/prefixed-libspecs 14})
25+
26+
(defdescribe env-logger-test
27+
(let [env-logger (delay (gl/procure "https://github.com/terop/env-logger.git"
28+
'terop/env-logger "1a82add79ae93ed5d935192a6261eb83c19dc0df"))
29+
results (delay
30+
(run-impl [{:path @env-logger}]
31+
{:config-override
32+
(-> (usefully-enabled-config)
33+
(assoc :silent true)
34+
(assoc :parallel false)
35+
(assoc :clojure-version {:major 1 :minor 11}))}))
36+
diagnostics (delay (->> @results
37+
:diagnostics
38+
(group-by :rule-name)
39+
(into (sorted-map))))]
40+
; (user/pprint (dissoc @diagnostics 'lint/warn-on-reflection))
41+
; (user/pprint (into (sorted-map) (update-vals* @diagnostics count)))
42+
(it "has the right diagnostics"
43+
(expect
44+
(match?
45+
(m/equals env-logger-diagnostics)
46+
(update-vals* @diagnostics count))))
47+
(it "sums correctly"
48+
(expect (= 109 (count (:diagnostics @results)))))
49+
(it "raises no errors"
50+
(expect (nil? (get diagnostics 'splint/error))))
51+
(it "raises no unknown errors"
52+
(expect (nil? (get diagnostics 'splint/unknown-error))))))
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; This Source Code Form is subject to the terms of the Mozilla Public
2+
; License, v. 2.0. If a copy of the MPL was not distributed with this
3+
; file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
(ns noahtheduke.splint.integrations.helpers
6+
(:require
7+
[noahtheduke.splint.clojure-ext.core :refer [update-vals*]]
8+
[noahtheduke.splint.config :refer [read-default-config]]))
9+
10+
(set! *warn-on-reflection* true)
11+
12+
(defn usefully-enabled-config []
13+
(-> (read-default-config)
14+
(update-vals* #(assoc % :enabled true))
15+
(assoc-in ['style/set-literal-as-fn :enabled] false)))

0 commit comments

Comments
 (0)