Skip to content

Commit

Permalink
Add splint to CI pipeline, fix existing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahTheDuke committed Nov 26, 2024
1 parent d2b1005 commit 71670fb
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 1 addition & 20 deletions .splint.edn
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Misc

- Add `splint` to CI.

## 1.4.1

Released `2024-11-21`.
Expand Down
6 changes: 3 additions & 3 deletions corpus/cli_filter_tests/a.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
6 changes: 3 additions & 3 deletions corpus/cli_filter_tests/b.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
4 changes: 2 additions & 2 deletions corpus/find_tests/examples.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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))
2 changes: 1 addition & 1 deletion src/clojure/lazytest/filter.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions src/clojure/lazytest/watch.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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 %)))))))
Expand Down

0 comments on commit 71670fb

Please sign in to comment.