From 71670fbfbeeedbded20a48023247d2161d3e2e7c Mon Sep 17 00:00:00 2001 From: Noah Bogart Date: Tue, 26 Nov 2024 13:41:51 -0500 Subject: [PATCH] Add splint to CI pipeline, fix existing errors --- .github/workflows/main.yml | 3 +++ .splint.edn | 21 +-------------------- CHANGELOG.md | 4 ++++ corpus/cli_filter_tests/a.clj | 6 +++--- corpus/cli_filter_tests/b.clj | 6 +++--- corpus/find_tests/examples.clj | 4 ++-- src/clojure/lazytest/filter.clj | 2 +- src/clojure/lazytest/watch.clj | 1 + 8 files changed, 18 insertions(+), 29 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 544c416..8f22c43 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,6 +45,9 @@ jobs: - name: clojure-lsp run: clojure-lsp diagnostics + - name: splint + run: clojure -M:provided:dev:test:splint + - name: tests run: | clojure -T:prep javac diff --git a/.splint.edn b/.splint.edn index a2c5866..e05c08e 100644 --- a/.splint.edn +++ b/.splint.edn @@ -6,14 +6,6 @@ ;; Using unquote-splicing on a body in a macro can lead to subtly broken code that's hard to debug. lint/body-unquote-splicing {:enabled false} - ;; Diagnostics count: 48 - ;; Specify a function name for defmethod bodies. - lint/defmethod-names {:enabled false} - - ;; Diagnostics count: 2 - ;; Prefer `vec` or `set` to `(into [] ...)`. - lint/into-literal {:enabled false} - ;; Diagnostics count: 50 ;; Prefer `(y x)` to `(-> x y)`. ;; :supported-styles [:inline :avoid-collections] @@ -23,18 +15,7 @@ ;; Always set *warn-on-reflection* to avoid reflection in interop. lint/warn-on-reflection {:enabled false} - ;; Diagnostics count: 22 - ;; Avoid functions longer than 10 lines of code (default). - ;; :supported-styles [:body :defn] - metrics/fn-length {:enabled false} - - ;; Diagnostics count: 14 - ;; Avoid calling assoc with multiple pairs. - performance/assoc-many {:enabled false} - - ;; Diagnostics count: 28 - ;; Rely on `.equals` when comparing against string literals. - performance/dot-equals {:enabled false} + style/def-fn {:enabled false} ;; Diagnostics count: 1 ;; Prefer `condp` to `cond` when testing same base case. diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b9cbf7..98d2292 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Misc + +- Add `splint` to CI. + ## 1.4.1 Released `2024-11-21`. diff --git a/corpus/cli_filter_tests/a.clj b/corpus/cli_filter_tests/a.clj index 551afa1..14cfa95 100644 --- a/corpus/cli_filter_tests/a.clj +++ b/corpus/cli_filter_tests/a.clj @@ -4,13 +4,13 @@ (defdescribe ^:on-var a-1-test (it "works" - (expect (+ 1 1)))) + (expect (+ 10 20)))) (defdescribe a-2-test {:in-attr-map true} (it "works" - (expect (+ 1 1)))) + (expect (+ 10 20)))) (defdescribe a-3-test (it "works" - (expect (+ 1 1)))) + (expect (+ 10 20)))) diff --git a/corpus/cli_filter_tests/b.clj b/corpus/cli_filter_tests/b.clj index 1c1a28c..e1dbb2e 100644 --- a/corpus/cli_filter_tests/b.clj +++ b/corpus/cli_filter_tests/b.clj @@ -4,12 +4,12 @@ (defdescribe b-1-test (it "works" - (expect (+ 1 1)))) + (expect (+ 10 20)))) (defdescribe b-2-test (it "works" - (expect (+ 1 1)))) + (expect (+ 10 20)))) (defdescribe b-3-test (it "works" - (expect (+ 1 1)))) + (expect (+ 10 20)))) diff --git a/corpus/find_tests/examples.clj b/corpus/find_tests/examples.clj index 78035f0..136bc99 100644 --- a/corpus/find_tests/examples.clj +++ b/corpus/find_tests/examples.clj @@ -3,7 +3,7 @@ [lazytest.core :refer [describe expect it]])) (defn test-fn - {:lazytest/test #(expect (= 0 (test-fn 1)))} + {:lazytest/test #(expect (zero? (test-fn 1)))} [a] (+ a a)) @@ -18,6 +18,6 @@ {:lazytest/test (describe "top level" (it "test-describe example" (expect (= 1 (test-describe 1)))) - (it "test-describe example two" (expect (= 0 (test-describe 1)))))} + (it "test-describe example two" (expect (zero? (test-describe 1)))))} [a] (+ a a)) diff --git a/src/clojure/lazytest/filter.clj b/src/clojure/lazytest/filter.clj index ba725b0..65e4799 100644 --- a/src/clojure/lazytest/filter.clj +++ b/src/clojure/lazytest/filter.clj @@ -86,7 +86,7 @@ filter-tree--lazytest-ns [ns-suite config] (let [var-filter (map (comp symbol namespace) (:var-filter config)) - ns-filter (not-empty (into #{} (concat var-filter (:ns-filter config))))] + ns-filter (not-empty (set (concat var-filter (:ns-filter config))))] (if ns-filter (when (ns-filter (:doc ns-suite)) (filter-suite ns-suite config)) diff --git a/src/clojure/lazytest/watch.clj b/src/clojure/lazytest/watch.clj index 35e5add..73f0724 100644 --- a/src/clojure/lazytest/watch.clj +++ b/src/clojure/lazytest/watch.clj @@ -13,6 +13,7 @@ (defn get-local-classpath [] (-> (System/getProperty "java.class.path") (str/split (re-pattern File/pathSeparator)) + #_{:splint/disable [lint/into-literal]} (->> (into [] (comp (map io/file) (remove #(File/.isAbsolute ^File %)))))))