diff --git a/.clj-kondo/imports/nl.jomco/with-resources/config.edn b/.clj-kondo/imports/nl.jomco/with-resources/config.edn new file mode 100644 index 0000000..7989117 --- /dev/null +++ b/.clj-kondo/imports/nl.jomco/with-resources/config.edn @@ -0,0 +1,8 @@ +;;; SPDX-FileCopyrightText: 2024 Jomco B.V. +;;; SPDX-FileContributor: Joost Diepenmaat +;;; +;;; SPDX-License-Identifier: MIT + +{:lint-as {nl.jomco.resources/with-resources clojure.core/with-open + nl.jomco.resources/mk-system clojure.core/let + nl.jomco.resources/defresource clojure.core/def}} diff --git a/.clj-kondo/imports/taoensso/encore/config.edn b/.clj-kondo/imports/taoensso/encore/config.edn new file mode 100644 index 0000000..766fd95 --- /dev/null +++ b/.clj-kondo/imports/taoensso/encore/config.edn @@ -0,0 +1,4 @@ +{:hooks + {:analyze-call + {taoensso.encore/defalias taoensso.encore/defalias + taoensso.encore/defn-cached taoensso.encore/defn-cached}}} diff --git a/.clj-kondo/imports/taoensso/encore/taoensso/encore.clj b/.clj-kondo/imports/taoensso/encore/taoensso/encore.clj new file mode 100644 index 0000000..4d2d96f --- /dev/null +++ b/.clj-kondo/imports/taoensso/encore/taoensso/encore.clj @@ -0,0 +1,37 @@ +(ns taoensso.encore + "I don't personally use clj-kondo, so these hooks are + kindly authored and maintained by contributors. + PRs very welcome! - Peter Taoussanis" + (:require + [clj-kondo.hooks-api :as hooks])) + +(defn defalias + [{:keys [node]}] + (let [[sym-raw src-raw] (rest (:children node)) + src (if src-raw src-raw sym-raw) + sym + (if src-raw + sym-raw + (symbol (name (hooks/sexpr src))))] + + {:node + (with-meta + (hooks/list-node + [(hooks/token-node 'def) + (hooks/token-node (hooks/sexpr sym)) + (hooks/token-node (hooks/sexpr src))]) + (meta src))})) + +(defn defn-cached + [{:keys [node] :as x}] + (let [[sym _opts binding-vec & body] (rest (:children node))] + {:node + (hooks/list-node + (list + (hooks/token-node 'def) + sym + (hooks/list-node + (list* + (hooks/token-node 'fn) + binding-vec + body))))})) diff --git a/.gitignore b/.gitignore index e7db612..82acc4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -.clj-kondo/ +.clj-kondo/.cache .cpcache/ .idea/ validator-service.iml diff --git a/Makefile b/Makefile index ab6c453..f3930a1 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,9 @@ classes/nl/surf/eduhub/validator/service/main.class: src/nl/surf/eduhub/validato target/eduhub-validator-service.jar: classes/nl/surf/eduhub/validator/service/main.class clojure -M:uberjar --main-class nl.surf.eduhub.validator.service.main --target $@ +prep-lint: + clojure -M:lint --lint $$(clojure -Spath) --copy-configs --dependencies --skip-lint + lint: clojure -M:lint diff --git a/src/nl/surf/eduhub/validator/service/api.clj b/src/nl/surf/eduhub/validator/service/api.clj index 6436aed..7e78924 100644 --- a/src/nl/surf/eduhub/validator/service/api.clj +++ b/src/nl/surf/eduhub/validator/service/api.clj @@ -101,7 +101,7 @@ (defn error-message-from-response [{:keys [status body]}] - (if (<= 400 status) + (when (<= 400 status) (or (:message body) (let [msg (string/replace (str body) #"\s+" " ")] (if (<= 300 (count msg)) @@ -111,7 +111,7 @@ (defn wrap-log [handler] (fn [request] - (try (let [{:keys [status body] :as response} (handler request)] + (try (let [{:keys [status] :as response} (handler request)] (if (<= 500 status) (log/error (str (:status response) " " (:request-method request) " " (:uri request))) (log/info (str (:status response) " " (:request-method request) " " (:uri request)))) diff --git a/src/nl/surf/eduhub/validator/service/jobs/client.clj b/src/nl/surf/eduhub/validator/service/jobs/client.clj index d51c2d5..0ecfcd7 100644 --- a/src/nl/surf/eduhub/validator/service/jobs/client.clj +++ b/src/nl/surf/eduhub/validator/service/jobs/client.clj @@ -1,8 +1,6 @@ (ns nl.surf.eduhub.validator.service.jobs.client (:require [clojure.tools.logging :as log] - [goose.brokers.redis.broker :as broker] [goose.client :as c] - [goose.retry :as retry] [nl.surf.eduhub.validator.service.jobs.status :as status] [nl.surf.eduhub.validator.service.jobs.worker :as worker]) (:import [java.util UUID])) diff --git a/src/nl/surf/eduhub/validator/service/main.clj b/src/nl/surf/eduhub/validator/service/main.clj index e104147..aacd9d5 100644 --- a/src/nl/surf/eduhub/validator/service/main.clj +++ b/src/nl/surf/eduhub/validator/service/main.clj @@ -19,7 +19,6 @@ (ns nl.surf.eduhub.validator.service.main (:gen-class) (:require [environ.core :refer [env]] - [goose.brokers.redis.broker :as broker] [goose.worker :as w] [nl.jomco.resources :refer [mk-system closeable with-resources wait-until-interrupted]] [nl.surf.eduhub.validator.service.api :as api] diff --git a/src/nl/surf/eduhub/validator/service/views/status.clj b/src/nl/surf/eduhub/validator/service/views/status.clj index 7973cf8..1b3aa19 100644 --- a/src/nl/surf/eduhub/validator/service/views/status.clj +++ b/src/nl/surf/eduhub/validator/service/views/status.clj @@ -30,7 +30,7 @@ [:script (h2/raw (str "var validationUuid = '" uuid "';"))] [:script {:src "/javascript/status.js"}] ;; Start polling for the status to change to "finished" or "failed" - [:script (when (= job-status "pending") (h2/raw (str "const polling = setInterval(pollJobStatus, pollInterval);")))]] + [:script (when (= job-status "pending") (h2/raw "const polling = setInterval(pollJobStatus, pollInterval);"))]] [:body [:div.profile-container [:h1 endpoint-id] diff --git a/test/nl/surf/eduhub/validator/service/authentication_test.clj b/test/nl/surf/eduhub/validator/service/authentication_test.clj index 3c607a7..8960c5c 100644 --- a/test/nl/surf/eduhub/validator/service/authentication_test.clj +++ b/test/nl/surf/eduhub/validator/service/authentication_test.clj @@ -88,7 +88,7 @@ "Not authorized when no token provided") (is (= http-status/forbidden - (:status (handler {:headers {"authorization" (str "Bearer invalid-token")}}))) + (:status (handler {:headers {"authorization" "Bearer invalid-token"}}))) "Forbidden with invalid token") (is (= 2 @count-calls) @@ -115,7 +115,7 @@ "Not authorized when no token provided") (is (= http-status/forbidden - (:status (handler {:headers {"authorization" (str "Bearer invalid-token")}}))) + (:status (handler {:headers {"authorization" "Bearer invalid-token"}}))) "Forbidden with invalid token") (is (= 2 @count-calls) diff --git a/test/nl/surf/eduhub/validator/service/jobs/client_test.clj b/test/nl/surf/eduhub/validator/service/jobs/client_test.clj index 8977c30..44009b6 100644 --- a/test/nl/surf/eduhub/validator/service/jobs/client_test.clj +++ b/test/nl/surf/eduhub/validator/service/jobs/client_test.clj @@ -2,7 +2,6 @@ (:require [babashka.http-client :as http] [babashka.json :as json] [clojure.test :refer [deftest is testing]] - [environ.core :refer [env]] [goose.client :as c] [nl.jomco.http-status-codes :as http-status] [nl.surf.eduhub.validator.service.jobs.status :as status]