Merge pull request #771 from mthl/lint

Fix linting issues and run Clj-kondo in CI
This commit is contained in:
Joel Kaasinen 2026-01-09 08:12:44 +02:00 committed by GitHub
commit 8907dfc5f5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 76 additions and 63 deletions

View file

@ -1,5 +1,6 @@
{;;:skip-comments true {;;:skip-comments true
:lint-as {potemkin/def-derived-map clojure.core/defrecord} :lint-as {potemkin/def-derived-map clojure.core/defrecord
clojure.test.check.clojure-test/defspec clojure.test/deftest}
:linters {:missing-else-branch {:level :off} :linters {:missing-else-branch {:level :off}
:unused-binding {:level :off} :unused-binding {:level :off}
:unused-referred-var {:exclude {clojure.test [deftest testing is are] :unused-referred-var {:exclude {clojure.test [deftest testing is are]

View file

@ -36,12 +36,16 @@ jobs:
uses: DeLaGuardo/setup-clojure@13.1 uses: DeLaGuardo/setup-clojure@13.1
with: with:
lein: 2.9.5 lein: 2.9.5
clj-kondo: 2025.12.23
# Install openapi-schema-validator for openapi-tests # Install openapi-schema-validator for openapi-tests
# Uses node version from the ubuntu-latest # Uses node version from the ubuntu-latest
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
- name: Run Linter
run: ./lint.sh
- name: Run tests - name: Run tests
run: ./scripts/test.sh clj run: ./scripts/test.sh clj

View file

@ -1,6 +1,5 @@
(ns frontend-re-frame.core (ns frontend-re-frame.core
(:require [re-frame.core :as re-frame] (:require [re-frame.core :as re-frame]
[reagent.core :as reagent]
[reagent.dom :as rd] [reagent.dom :as rd]
[reitit.core :as r] [reitit.core :as r]
[reitit.coercion.spec :as rss] [reitit.coercion.spec :as rss]

View file

@ -12,7 +12,6 @@
[reitit.ring.middleware.multipart :as multipart] [reitit.ring.middleware.multipart :as multipart]
[reitit.ring.middleware.parameters :as parameters] [reitit.ring.middleware.parameters :as parameters]
[ring.adapter.jetty :as jetty] [ring.adapter.jetty :as jetty]
[malli.core :as malli]
[muuntaja.core :as m])) [muuntaja.core :as m]))
(def Transaction (def Transaction

View file

@ -244,7 +244,7 @@
(if coercer (if coercer
(let [result (coercer query-params :default)] (let [result (coercer query-params :default)]
(if (error? result) (if (error? result)
(throw (ex-info (str "Query parameters coercion failed") (throw (ex-info "Query parameters coercion failed"
result)) result))
result)) result))
query-params)))) query-params))))

View file

@ -7,6 +7,10 @@
([type data] ([type data]
(throw (ex-info (str type) {:type type, :data data})))) (throw (ex-info (str type) {:type type, :data data}))))
(defn unsupported-protocol-method!
[method]
(fail! :unsupported-protocol-method {:method method}))
(defn get-message [e] (defn get-message [e]
#?(:clj (.getMessage ^Exception e) :cljs (ex-message e))) #?(:clj (.getMessage ^Exception e) :cljs (ex-message e)))

View file

@ -1,7 +1,6 @@
(ns ^:no-doc reitit.impl (ns ^:no-doc reitit.impl
#?(:cljs (:require-macros [reitit.impl])) #?(:cljs (:require-macros [reitit.impl]))
(:require [clojure.set :as set] (:require [clojure.string :as str]
[clojure.string :as str]
[meta-merge.core :as mm] [meta-merge.core :as mm]
[reitit.exception :as ex] [reitit.exception :as ex]
[reitit.trie :as trie]) [reitit.trie :as trie])

View file

@ -174,7 +174,7 @@
;; TODO: this is hack, but seems to work and is safe. ;; TODO: this is hack, but seems to work and is safe.
(defn source-str [[target _ file line]] (defn source-str [[target _ file line]]
(try (try
(if (and (not= 1 line)) (if (not= 1 line)
(let [file-name (str/replace file #"(.*?)\.\S[^\.]+" "$1") (let [file-name (str/replace file #"(.*?)\.\S[^\.]+" "$1")
target-name (name target) target-name (name target)
ns (str (subs target-name 0 (or (str/index-of target-name (str file-name "$")) 0)) file-name)] ns (str (subs target-name 0 (or (str/index-of target-name (str file-name "$")) 0)) file-name)]
@ -190,7 +190,7 @@
(color :title message " ") (color :title message " ")
(color :title-dark (repeat-str "-" between) " ") (color :title-dark (repeat-str "-" between) " ")
(color :title source) " " (color :title source) " "
(color :title-dark (str "--"))])) (color :title-dark "--")]))
(defn footer [{:keys [width]}] (defn footer [{:keys [width]}]
(color :title-dark (repeat-str "-" width))) (color :title-dark (repeat-str "-" width)))

View file

@ -22,12 +22,12 @@
compile (fn [[path data] opts scope] compile (fn [[path data] opts scope]
(interceptor/compile-result [path data] opts scope)) (interceptor/compile-result [path data] opts scope))
->endpoint (fn [p d m s] ->endpoint (fn [p d m s]
(let [d (ring/-compile-coercion d)] (let [d (ring/-compile-coercion d)
(let [compiled (compile [p d] opts s)] compiled (compile [p d] opts s)]
(-> compiled (-> compiled
(map->Endpoint) (map->Endpoint)
(assoc :path p) (assoc :path p)
(assoc :method m))))) (assoc :method m))))
->methods (fn [any? data] ->methods (fn [any? data]
(reduce (reduce
(fn [acc method] (fn [acc method]

View file

@ -2,10 +2,10 @@
(:require [io.pedestal.http :as http] (:require [io.pedestal.http :as http]
[io.pedestal.interceptor :as interceptor] [io.pedestal.interceptor :as interceptor]
[io.pedestal.interceptor.chain :as chain] [io.pedestal.interceptor.chain :as chain]
[reitit.exception :as ex]
[reitit.http] [reitit.http]
[reitit.interceptor]) [reitit.interceptor])
(:import (java.lang.reflect Method) (:import (java.lang.reflect Method)))
(reitit.interceptor Executor)))
;; TODO: variadic ;; TODO: variadic
(defn- arities [f] (defn- arities [f]
@ -46,12 +46,16 @@
(def pedestal-executor (def pedestal-executor
(reify (reify
Executor reitit.interceptor/Executor
(queue [_ interceptors] (queue [_ interceptors]
(->> interceptors (->> interceptors
(map (fn [{::interceptor/keys [handler] :as interceptor}] (map (fn [{::interceptor/keys [handler] :as interceptor}]
(or handler interceptor))) (or handler interceptor)))
(keep ->interceptor))) (keep ->interceptor)))
(execute [_ _ _]
(ex/unsupported-protocol-method! 'reitit.interceptor/execute))
(execute [_ _ _ _ _]
(ex/unsupported-protocol-method! 'reitit.interceptor/execute))
(enqueue [_ context interceptors] (enqueue [_ context interceptors]
(chain/enqueue context interceptors)))) (chain/enqueue context interceptors))))

View file

@ -1,5 +1,6 @@
(ns reitit.interceptor.sieppari (ns reitit.interceptor.sieppari
(:require [reitit.interceptor :as interceptor] (:require [reitit.exception :as ex]
[reitit.interceptor :as interceptor]
[sieppari.core :as sieppari] [sieppari.core :as sieppari]
[sieppari.queue :as queue])) [sieppari.queue :as queue]))
@ -15,4 +16,6 @@
(execute [_ interceptors request] (execute [_ interceptors request]
(sieppari/execute interceptors request)) (sieppari/execute interceptors request))
(execute [_ interceptors request respond raise] (execute [_ interceptors request respond raise]
(sieppari/execute interceptors request respond raise)))) (sieppari/execute interceptors request respond raise))
(enqueue [_ _ _]
(ex/unsupported-protocol-method! 'reitit.interceptor/enqueue))))

View file

@ -80,12 +80,15 @@
(defrecord NoOpCoercion [] (defrecord NoOpCoercion []
coercion/Coercion coercion/Coercion
(-get-name [_] :no-op) (-get-name [_] :no-op)
(-get-options [_])
(-get-apidocs [_ _ {:keys [parameters responses] :as info}]) (-get-apidocs [_ _ {:keys [parameters responses] :as info}])
(-get-model-apidocs [_ _ _ _])
(-compile-model [_ model _] model) (-compile-model [_ model _] model)
(-open-model [_ spec] spec) (-open-model [_ spec] spec)
(-encode-error [_ error] error) (-encode-error [_ error] error)
(-request-coercer [_ type spec] (fn [value format] value)) (-request-coercer [_ type spec] (fn [value format] value))
(-response-coercer [this spec] (coercion/request-coercer this :response spec {}))) (-response-coercer [this spec] (coercion/request-coercer this :response spec {}))
(-query-string-coercer [_ _]))
(comment (comment
(doseq [coercion [nil (->NoOpCoercion) spec/coercion]] (doseq [coercion [nil (->NoOpCoercion) spec/coercion]]

View file

@ -53,27 +53,27 @@
request (json-request data) request (json-request data)
request! (request-stream request)]] request! (request-stream request)]]
"10b" ;; # 10b
;; 38µs (c-api 1.x) ;; 38µs (c-api 1.x)
;; 14µs (c-api 2.0.0-alpha21) ;; 14µs (c-api 2.0.0-alpha21)
;; 6µs ;; 6µs
"100b" ;; # 100b
;; 74µs (c-api 1.x) ;; 74µs (c-api 1.x)
;; 16µs (c-api 2.0.0-alpha21) ;; 16µs (c-api 2.0.0-alpha21)
;; 8µs ;; 8µs
"1k" ;; # 1k
;; 322µs (c-api 1.x) ;; 322µs (c-api 1.x)
;; 24µs (c-api 2.0.0-alpha21) ;; 24µs (c-api 2.0.0-alpha21)
;; 16µs ;; 16µs
"10k" ;; # 10k
;; 3300µs (c-api 1.x) ;; 3300µs (c-api 1.x)
;; 120µs (c-api 2.0.0-alpha21) ;; 120µs (c-api 2.0.0-alpha21)
;; 110µs ;; 110µs
"100k" ;; # 100k
;; 10600µs (c-api 1.x) ;; 10600µs (c-api 1.x)
;; 1100µs (c-api 2.0.0-alpha21) ;; 1100µs (c-api 2.0.0-alpha21)
;; 1100µs ;; 1100µs

View file

@ -37,40 +37,40 @@
(defn routing-test [] (defn routing-test []
;; 21385 / 14337 ;; 21385 / 14337
"barista" ;; "barista"
;; 26259 / 25571 ;; 26259 / 25571
"choreographer" ;; "choreographer"
;; 24277 / 19174 ;; 24277 / 19174
"clutch" ;; "clutch"
;; 26158 / 25584 ;; 26158 / 25584
"connect" ;; "connect"
;; 24614 / 25413 ;; 24614 / 25413
"escort" ;; "escort"
;; 21979 / 18595 ;; 21979 / 18595
"express" ;; "express"
;; 23123 / 25405 ;; 23123 / 25405
"find-my-way" ;; "find-my-way"
;; 24798 / 25286 ;; 24798 / 25286
"http-hash" ;; "http-hash"
;; 24215 / 23670 ;; 24215 / 23670
"i40" ;; "i40"
;; 23561 / 26278 ;; 23561 / 26278
"light-router" ;; "light-router"
;; 28362 / 30056 ;; 28362 / 30056
"http-raw" ;; "http-raw"
;; 25310 / 25126 ;; 25310 / 25126
"regex" ;; "regex"
;; 112719 / 113959 ;; 112719 / 113959
(title "reitit") (title "reitit")

View file

@ -308,10 +308,10 @@
["/ping" {:get {:interceptors [{:enter #(a/go %)}] ["/ping" {:get {:interceptors [{:enter #(a/go %)}]
:handler (fn [_] (a/go response))}}]) :handler (fn [_] (a/go response))}}])
(ring/create-default-handler) (ring/create-default-handler)
{:executor sieppari/executor})] {:executor sieppari/executor})
(let [respond (promise)] respond (promise)]
(app {:request-method :get, :uri "/ping"} respond ::irrelevant) (app {:request-method :get, :uri "/ping"} respond ::irrelevant)
(is (= response (deref respond 100 ::timeout))))))) (is (= response (deref respond 100 ::timeout))))))
(defrecord MyAsyncContext []) (defrecord MyAsyncContext [])

View file

@ -2,7 +2,6 @@
(:require [clojure.spec.alpha :as cs] (:require [clojure.spec.alpha :as cs]
[clojure.string :as str] [clojure.string :as str]
[clojure.test :refer [deftest is testing]] [clojure.test :refer [deftest is testing]]
[malli.core :as m]
[malli.experimental.lite :as l] [malli.experimental.lite :as l]
[reitit.coercion :as coercion] [reitit.coercion :as coercion]
[reitit.coercion.malli] [reitit.coercion.malli]
@ -10,8 +9,7 @@
[reitit.coercion.spec] [reitit.coercion.spec]
[reitit.core :as r] [reitit.core :as r]
[schema.core :as s] [schema.core :as s]
[spec-tools.data-spec :as ds] [spec-tools.data-spec :as ds])
[malli.transform :as mt])
#?(:clj #?(:clj
(:import (clojure.lang ExceptionInfo)))) (:import (clojure.lang ExceptionInfo))))
@ -110,7 +108,6 @@
(testing "spec-coercion (shallow)" (testing "spec-coercion (shallow)"
(testing "succeeds" (testing "succeeds"
(let [m (r/match-by-path r "/spec-shallow/1/abba")] (let [m (r/match-by-path r "/spec-shallow/1/abba")]
(def MATCH m)
(is (= {:path {:keyword :abba, :number 1}, :query nil} (is (= {:path {:keyword :abba, :number 1}, :query nil}
(coercion/coerce! m)))) (coercion/coerce! m))))
(let [m (r/match-by-path r "/spec-shallow/1/abba")] (let [m (r/match-by-path r "/spec-shallow/1/abba")]

View file

@ -1,10 +1,9 @@
(ns reitit.core-test (ns reitit.core-test
(:require [clojure.test :refer [are deftest is testing]] (:require [clojure.test :refer [are deftest is testing]]
[reitit.core :as r #?@(:cljs [:refer [Router]])] [reitit.core :as r]
[reitit.impl :as impl]) [reitit.impl :as impl])
#?(:clj #?(:clj
(:import (clojure.lang ExceptionInfo) (:import (clojure.lang ExceptionInfo))))
(reitit.core Router))))
(defn- var-handler [& _] (defn- var-handler [& _]
"var-handler") "var-handler")
@ -261,10 +260,12 @@
(is (= #'var-handler result)))))) (is (= #'var-handler result))))))
(testing "custom router" (testing "custom router"
(let [router (r/router ["/ping"] {:router (fn [_ _] (let [router (r/router
(reify Router ["/ping"]
(r/router-name [_] {:router (fn [_ _]
::custom)))})] #_{:clj-kondo/ignore [:missing-protocol-method]}
(reify r/Router
(router-name [_] ::custom)))})]
(is (= ::custom (r/router-name router))))) (is (= ::custom (r/router-name router)))))
(testing "bide sample" (testing "bide sample"

View file

@ -4,7 +4,6 @@
[jsonista.core :as j] [jsonista.core :as j]
[malli.core :as mc] [malli.core :as mc]
[matcher-combinators.test :refer [match?]] [matcher-combinators.test :refer [match?]]
[matcher-combinators.matchers :as matchers]
[muuntaja.core :as m] [muuntaja.core :as m]
[reitit.coercion.malli :as malli] [reitit.coercion.malli :as malli]
[reitit.coercion.schema :as schema] [reitit.coercion.schema :as schema]

View file

@ -4,18 +4,18 @@
#?@(:clj [[muuntaja.core] #?@(:clj [[muuntaja.core]
[muuntaja.middleware] [muuntaja.middleware]
[jsonista.core :as j] [jsonista.core :as j]
[reitit.ring.middleware.muuntaja]]) [reitit.coercion.schema :as schema]
[reitit.ring.middleware.muuntaja]
[schema.core :as s]])
[malli.core :as m] [malli.core :as m]
[malli.util :as mu] [malli.util :as mu]
[meta-merge.core :refer [meta-merge]] [meta-merge.core :refer [meta-merge]]
[reitit.coercion.malli :as malli] [reitit.coercion.malli :as malli]
[reitit.coercion.schema :as schema]
[reitit.coercion.spec :as spec] [reitit.coercion.spec :as spec]
[reitit.core :as r] [reitit.core :as r]
[reitit.ring :as ring] [reitit.ring :as ring]
[reitit.ring.spec] [reitit.ring.spec]
[reitit.ring.coercion :as rrc] [reitit.ring.coercion :as rrc]
[schema.core :as s]
[clojure.spec.alpha] [clojure.spec.alpha]
[spec-tools.data-spec :as ds]) [spec-tools.data-spec :as ds])
#?(:clj #?(:clj

View file

@ -4,7 +4,8 @@
[reitit.core :as r] [reitit.core :as r]
[reitit.middleware :as middleware] [reitit.middleware :as middleware]
[reitit.ring :as ring] [reitit.ring :as ring]
[reitit.trie :as trie]) #?(:clj [reitit.trie :as trie]
:cljs [reitit.trie :as-alias trie]))
#?(:clj #?(:clj
(:import (clojure.lang ExceptionInfo)))) (:import (clojure.lang ExceptionInfo))))
@ -847,23 +848,22 @@
(let [body (:body (app {:request-method :get, :uri (str "/" n)}))] (let [body (:body (app {:request-method :get, :uri (str "/" n)}))]
(is (= body (str n)))))))))))) (is (= body (str n))))))))))))
(declare routes) (def routes (atom nil))
(deftest reloading-ring-handler-test (deftest reloading-ring-handler-test
(let [r (fn [body] {:status 200, :body body})] (let [r (fn [body] {:status 200, :body body})]
(def routes ["/" (constantly (r "1"))]) ;; initial value (reset! routes ["/" (constantly (r "1"))]) ;; initial value
(let [create-handler (fn [] (ring/ring-handler (ring/router @routes)))]
(let [create-handler (fn [] (ring/ring-handler (ring/router routes)))]
(testing "static ring handler does not see underlying route changes" (testing "static ring handler does not see underlying route changes"
(let [app (create-handler)] (let [app (create-handler)]
(is (= (r "1") (app {:uri "/", :request-method :get}))) (is (= (r "1") (app {:uri "/", :request-method :get})))
(def routes ["/" (constantly (r "2"))]) ;; redefine (reset! routes ["/" (constantly (r "2"))]) ;; redefine
(is (= (r "1") (app {:uri "/", :request-method :get}))))) (is (= (r "1") (app {:uri "/", :request-method :get})))))
(testing "reloading ring handler sees underlying route changes" (testing "reloading ring handler sees underlying route changes"
(let [app (ring/reloading-ring-handler create-handler)] (let [app (ring/reloading-ring-handler create-handler)]
(is (= (r "2") (app {:uri "/", :request-method :get}))) (is (= (r "2") (app {:uri "/", :request-method :get})))
(def routes ["/" (constantly (r "3"))]) ;; redefine again (reset! routes ["/" (constantly (r "3"))]) ;; redefine again
(is (= (r "3") (app {:uri "/", :request-method :get})))))))) (is (= (r "3") (app {:uri "/", :request-method :get}))))))))
(defrecord FooTest [a b]) (defrecord FooTest [a b])