Skip to content

Commit c4e84c2

Browse files
committed
Add clj-kondo and fix most linting warnings
1 parent c214622 commit c4e84c2

File tree

47 files changed

+178
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+178
-181
lines changed

.clj-kondo/config.edn

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{;;:skip-comments true
2+
:lint-as {potemkin/def-derived-map clojure.core/defrecord}
3+
:linters {:if {:level :off}
4+
:unused-binding {:level :off}
5+
:unused-referred-var {:exclude {clojure.test [deftest testing is are]
6+
cljs.test [deftest testing is are]}}}}

Justfile

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
help:
2+
@just --list
3+
4+
# Initializes lint
5+
init-lint:
6+
clj-kondo --lint $(lein classpath)
7+
8+
# Lints the project
9+
lint:
10+
./lint.sh

examples/frontend-auth/src/backend/server.clj

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns backend.server
2-
(:require [clojure.java.io :as io]
3-
[ring.util.response :as resp]
2+
(:require [ring.util.response :as resp]
43
[ring.middleware.content-type :as content-type]))
54

65
(def handler

examples/frontend-auth/src/frontend/core.cljs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
[reitit.frontend :as rf]
44
[reitit.frontend.easy :as rfe]
55
[reitit.frontend.controllers :as rfc]
6-
[reitit.coercion :as rc]
76
[reitit.coercion.schema :as rsc]
87
[schema.core :as s]
98
[fipp.edn :as fedn]))

examples/frontend-controllers/src/backend/server.clj

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns backend.server
2-
(:require [clojure.java.io :as io]
3-
[ring.util.response :as resp]
2+
(:require [ring.util.response :as resp]
43
[ring.middleware.content-type :as content-type]))
54

65
(def handler

examples/frontend-controllers/src/frontend/core.cljs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
[reitit.frontend :as rf]
44
[reitit.frontend.easy :as rfe]
55
[reitit.frontend.controllers :as rfc]
6-
[reitit.coercion :as rc]
76
[reitit.coercion.schema :as rsc]
87
[schema.core :as s]
98
[fipp.edn :as fedn]))

examples/frontend-links/src/backend/server.clj

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns backend.server
2-
(:require [clojure.java.io :as io]
3-
[ring.util.response :as resp]
2+
(:require [ring.util.response :as resp]
43
[ring.middleware.content-type :as content-type]))
54

65
(def handler

examples/frontend-links/src/frontend/core.cljs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
(:require [clojure.string :as string]
33
[fipp.edn :as fedn]
44
[reagent.core :as r]
5-
[reitit.coercion :as rc]
65
[reitit.coercion.spec :as rss]
76
[reitit.frontend :as rf]
87
[reitit.frontend.easy :as rfe]

examples/frontend-prompt/src/backend/server.clj

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns backend.server
2-
(:require [clojure.java.io :as io]
3-
[ring.util.response :as resp]
2+
(:require [ring.util.response :as resp]
43
[ring.middleware.content-type :as content-type]))
54

65
(def handler

examples/frontend-prompt/src/frontend/core.cljs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
(ns frontend.core
22
(:require [fipp.edn :as fedn]
33
[reagent.core :as r]
4-
[reitit.coercion :as rc]
54
[reitit.coercion.spec :as rss]
65
[reitit.frontend :as rf]
7-
[reitit.frontend.easy :as rfe]
8-
[spec-tools.data-spec :as ds]))
6+
[reitit.frontend.easy :as rfe]))
97

108
;; Implementing conditional prompt on navigation with Reitit frontend.
119

examples/frontend-re-frame/src/clj/backend/server.clj

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns backend.server
2-
(:require [clojure.java.io :as io]
3-
[ring.util.response :as resp]
2+
(:require [ring.util.response :as resp]
43
[ring.middleware.content-type :as content-type]))
54

65
(def handler

examples/frontend-re-frame/src/cljs/frontend_re_frame/core.cljs

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
(ns frontend-re-frame.core
2-
(:require
3-
[re-frame.core :as re-frame]
4-
[reagent.core :as reagent]
5-
[reitit.core :as r]
6-
[reitit.coercion :as rc]
7-
[reitit.coercion.spec :as rss]
8-
[reitit.frontend :as rf]
9-
[reitit.frontend.controllers :as rfc]
10-
[reitit.frontend.easy :as rfe]))
2+
(:require [re-frame.core :as re-frame]
3+
[reagent.core :as reagent]
4+
[reitit.core :as r]
5+
[reitit.coercion.spec :as rss]
6+
[reitit.frontend :as rf]
7+
[reitit.frontend.controllers :as rfc]
8+
[reitit.frontend.easy :as rfe]))
119

1210
;;; Events ;;;
1311

examples/frontend/src/backend/server.clj

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
(ns backend.server
2-
(:require [clojure.java.io :as io]
3-
[ring.util.response :as resp]
2+
(:require [ring.util.response :as resp]
43
[ring.middleware.content-type :as content-type]))
54

65
(def handler

examples/frontend/src/frontend/core.cljs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
(:require [reagent.core :as r]
33
[reitit.frontend :as rf]
44
[reitit.frontend.easy :as rfe]
5-
[reitit.coercion :as rc]
65
[reitit.coercion.spec :as rss]
76
[spec-tools.data-spec :as ds]
87
[fipp.edn :as fedn]))

examples/http-swagger/src/example/server.clj

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
[reitit.http.interceptors.muuntaja :as muuntaja]
1212
[reitit.http.interceptors.exception :as exception]
1313
[reitit.http.interceptors.multipart :as multipart]
14-
[reitit.http.interceptors.dev :as dev]
15-
[reitit.http.spec :as spec]
16-
[spec-tools.spell :as spell]
14+
;; Uncomment to use
15+
; [reitit.http.interceptors.dev :as dev]
16+
; [reitit.http.spec :as spec]
17+
; [spec-tools.spell :as spell]
1718
[ring.adapter.jetty :as jetty]
1819
[aleph.http :as aleph]
1920
[muuntaja.core :as m]

examples/pedestal-swagger/src/example/server.clj

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
[reitit.http.interceptors.muuntaja :as muuntaja]
1212
[reitit.http.interceptors.exception :as exception]
1313
[reitit.http.interceptors.multipart :as multipart]
14-
[reitit.http.interceptors.dev :as dev]
15-
[reitit.http.spec :as spec]
16-
[spec-tools.spell :as spell]
17-
[io.pedestal.http :as server]
14+
;; Uncomment to use
15+
; [reitit.http.interceptors.dev :as dev]
16+
; [reitit.http.spec :as spec]
17+
; [spec-tools.spell :as spell]
1818
[reitit.pedestal :as pedestal]
1919
[clojure.core.async :as a]
2020
[clojure.java.io :as io]

examples/ring-malli-swagger/test/example/server_test.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(ns example.server-test
2-
(:require [clojure.test :refer :all]
2+
(:require [clojure.test :refer [deftest testing is]]
33
[example.server :refer [app]]
44
[ring.mock.request :refer [request json-body]]))
55

examples/ring-spec-swagger/src/example/server.clj

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
[reitit.ring.middleware.exception :as exception]
1010
[reitit.ring.middleware.multipart :as multipart]
1111
[reitit.ring.middleware.parameters :as parameters]
12-
[reitit.ring.middleware.dev :as dev]
13-
[reitit.ring.spec :as spec]
14-
[spec-tools.spell :as spell]
12+
;; Uncomment to use
13+
; [reitit.ring.middleware.dev :as dev]
14+
; [reitit.ring.spec :as spec]
15+
; [spec-tools.spell :as spell]
1516
[ring.adapter.jetty :as jetty]
1617
[muuntaja.core :as m]
1718
[clojure.spec.alpha :as s]

examples/ring-spec-swagger/test/example/server_test.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(ns example.server-test
2-
(:require [clojure.test :refer :all]
2+
(:require [clojure.test :refer [deftest testing is]]
33
[example.server :refer [app]]
44
[ring.mock.request :refer [request json-body]]))
55

examples/ring-swagger/src/example/server.clj

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
[reitit.ring.middleware.exception :as exception]
1010
[reitit.ring.middleware.multipart :as multipart]
1111
[reitit.ring.middleware.parameters :as parameters]
12-
[reitit.ring.middleware.dev :as dev]
13-
[reitit.ring.spec :as spec]
14-
[spec-tools.spell :as spell]
12+
;; Uncomment to use
13+
; [reitit.ring.middleware.dev :as dev]
14+
; [reitit.ring.spec :as spec]
15+
; [spec-tools.spell :as spell]
1516
[ring.adapter.jetty :as jetty]
1617
[muuntaja.core :as m]
1718
[clojure.java.io :as io]))

lint.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
EXIT=0
4+
5+
clj-kondo --lint modules/*/src test perf-test
6+
EXIT=$(( EXIT + $? ))
7+
8+
for file in examples/*/src; do
9+
echo
10+
echo "Linting $file"
11+
clj-kondo --lint "$file"
12+
EXIT=$(( EXIT + $? ))
13+
done
14+
15+
exit $EXIT

modules/reitit-core/src/reitit/impl.cljc

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
[clojure.set :as set]
55
[meta-merge.core :as mm]
66
[reitit.trie :as trie]
7-
[reitit.exception :as exception]
87
[reitit.exception :as ex])
98
#?(:clj
10-
(:import (java.util.regex Pattern)
11-
(java.util HashMap Map)
9+
(:import (java.util HashMap Map)
1210
(java.net URLEncoder URLDecoder))))
1311

1412
(defn parse [path opts]
@@ -138,7 +136,7 @@
138136
(when-not (every? #(contains? path-params %) required)
139137
(let [defined (-> path-params keys set)
140138
missing (set/difference required defined)]
141-
(exception/fail!
139+
(ex/fail!
142140
(str "missing path-params for route " template " -> " missing)
143141
{:path-params path-params, :required required}))))
144142

modules/reitit-dev/src/reitit/dev/pretty.cljc

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
[reitit.exception :as exception]
55
[arrangement.core]
66
;; spell-spec
7-
[spec-tools.spell :as spell]
87
[spell-spec.expound]
98
;; expound
109
[expound.ansi]

modules/reitit-frontend/src/reitit/frontend.cljs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
(ns reitit.frontend
22
(:require [clojure.set :as set]
33
[reitit.coercion :as coercion]
4-
[reitit.coercion :as rc]
54
[reitit.core :as r])
65
(:import goog.Uri
76
goog.Uri.QueryData))
87

9-
(defn- query-param [^goog.Uri.QueryData q k]
8+
(defn- query-param [^QueryData q k]
109
(let [vs (.getValues q k)]
1110
(if (< (alength vs) 2)
1211
(aget vs 0)
1312
(vec vs))))
1413

1514
(defn query-params
1615
"Given goog.Uri, read query parameters into Clojure map."
17-
[^goog.Uri uri]
16+
[^Uri uri]
1817
(let [q (.getQueryData uri)]
1918
(->> q
2019
(.getKeys)
@@ -51,7 +50,7 @@
5150
([raw-routes]
5251
(router raw-routes {}))
5352
([raw-routes opts]
54-
(r/router raw-routes (merge {:compile rc/compile-request-coercers} opts))))
53+
(r/router raw-routes (merge {:compile coercion/compile-request-coercers} opts))))
5554

5655
(defn match-by-name!
5756
"Logs problems using console.warn"

modules/reitit-frontend/src/reitit/frontend/history.cljs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"Provides integration to hash-change or HTML5 History
33
events."
44
(:require [reitit.core :as reitit]
5-
[reitit.core :as r]
65
[reitit.frontend :as rf]
76
[goog.events :as gevents])
87
(:import goog.Uri))
@@ -59,9 +58,10 @@
5958
el
6059
(recur (.-parentNode el)))))))
6160

62-
(defn- event-target [event]
61+
(defn- event-target
6362
"Read event's target from composed path to get shadow dom working,
64-
fallback to target property if not available"
63+
fallback to target property if not available"
64+
[event]
6565
(let [original-event (.getBrowserEvent event)]
6666
(if (exists? (.-composedPath original-event))
6767
(aget (.composedPath original-event) 0)
@@ -176,7 +176,7 @@
176176
(href history k params nil))
177177
([history k params query]
178178
(let [match (rf/match-by-name! (:router history) k params)]
179-
(-href history (r/match->path match query)))))
179+
(-href history (reitit/match->path match query)))))
180180

181181
(defn push-state
182182
"Sets the new route, leaving previous route in history."
@@ -186,7 +186,7 @@
186186
(push-state history k params nil))
187187
([history k params query]
188188
(let [match (rf/match-by-name! (:router history) k params)
189-
path (r/match->path match query)]
189+
path (reitit/match->path match query)]
190190
;; pushState and replaceState don't trigger popstate event so call on-navigate manually
191191
(.pushState js/window.history nil "" (-href history path))
192192
(-on-navigate history path))))
@@ -199,6 +199,6 @@
199199
(replace-state history k params nil))
200200
([history k params query]
201201
(let [match (rf/match-by-name! (:router history) k params)
202-
path (r/match->path match query)]
202+
path (reitit/match->path match query)]
203203
(.replaceState js/window.history nil "" (-href history path))
204204
(-on-navigate history path))))

modules/reitit-http/src/reitit/http/coercion.cljc

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
(let [coercers (coercion/response-coercers coercion responses opts)]
4444
{:leave (fn [ctx]
4545
(let [request (:request ctx)
46-
response (:response ctx)]
47-
(let [response (coercion/coerce-response coercers request response)]
48-
(assoc ctx :response response))))})))})
46+
response (:response ctx)
47+
response (coercion/coerce-response coercers request response)]
48+
(assoc ctx :response response)))})))})
4949

5050
(defn coerce-exceptions-interceptor
5151
"Interceptor for handling coercion exceptions.

modules/reitit-swagger-ui/src/reitit/swagger_ui.cljc

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
(ns reitit.swagger-ui
2-
(:require [clojure.string :as str]
3-
[reitit.ring :as ring]
4-
#?@(:clj [
5-
[jsonista.core :as j]])))
2+
#?(:clj (:require [reitit.ring :as ring]
3+
[jsonista.core :as j])))
64

75
#?(:clj
86
(defn create-swagger-ui-handler

modules/reitit-swagger/src/reitit/swagger.cljc

+7-6
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@
6767
(defn- swagger-path [path opts]
6868
(-> path (trie/normalize opts) (str/replace #"\{\*" "{")))
6969

70-
(defn create-swagger-handler []
70+
(defn create-swagger-handler
7171
"Create a ring handler to emit swagger spec. Collects all routes from router which have
7272
an intersecting `[:swagger :id]` and which are not marked with `:no-doc` route data."
73+
[]
7374
(fn create-swagger
7475
([{::r/keys [router match] :keys [request-method]}]
7576
(let [{:keys [id] :or {id ::default} :as swagger} (-> match :result request-method :data :swagger)
@@ -95,11 +96,11 @@
9596
(strip-top-level-keys swagger))]))
9697
transform-path (fn [[p _ c]]
9798
(if-let [endpoint (some->> c (keep transform-endpoint) (seq) (into {}))]
98-
[(swagger-path p (r/options router)) endpoint]))]
99-
(let [map-in-order #(->> % (apply concat) (apply array-map))
100-
paths (->> router (r/compiled-routes) (filter accept-route) (map transform-path) map-in-order)]
101-
{:status 200
102-
:body (meta-merge swagger {:paths paths})})))
99+
[(swagger-path p (r/options router)) endpoint]))
100+
map-in-order #(->> % (apply concat) (apply array-map))
101+
paths (->> router (r/compiled-routes) (filter accept-route) (map transform-path) map-in-order)]
102+
{:status 200
103+
:body (meta-merge swagger {:paths paths})}))
103104
([req res raise]
104105
(try
105106
(res (create-swagger req))

perf-test/clj/reitit/bide_perf_test.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(ns reitit.bide-perf-test
22
(:require [criterium.core :as cc]
33
[reitit.core :as reitit]
4-
[reitit.perf-utils :refer :all]
4+
[reitit.perf-utils :refer [suite title]]
55

66
[bidi.bidi :as bidi]
77
[ataraxy.core :as ataraxy]

0 commit comments

Comments
 (0)