Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
joodie committed Jan 22, 2025
1 parent 2405c87 commit c21b84a
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 10 deletions.
8 changes: 8 additions & 0 deletions .clj-kondo/imports/nl.jomco/with-resources/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
;;; SPDX-FileCopyrightText: 2024 Jomco B.V.
;;; SPDX-FileContributor: Joost Diepenmaat <[email protected]>
;;;
;;; 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}}
4 changes: 4 additions & 0 deletions .clj-kondo/imports/taoensso/encore/config.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{:hooks
{:analyze-call
{taoensso.encore/defalias taoensso.encore/defalias
taoensso.encore/defn-cached taoensso.encore/defn-cached}}}
37 changes: 37 additions & 0 deletions .clj-kondo/imports/taoensso/encore/taoensso/encore.clj
Original file line number Diff line number Diff line change
@@ -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))))}))
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.clj-kondo/
.clj-kondo/.cache
.cpcache/
.idea/
validator-service.iml
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/nl/surf/eduhub/validator/service/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))))
Expand Down
2 changes: 0 additions & 2 deletions src/nl/surf/eduhub/validator/service/jobs/client.clj
Original file line number Diff line number Diff line change
@@ -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]))
Expand Down
1 change: 0 additions & 1 deletion src/nl/surf/eduhub/validator/service/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion src/nl/surf/eduhub/validator/service/views/status.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions test/nl/surf/eduhub/validator/service/authentication_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion test/nl/surf/eduhub/validator/service/jobs/client_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit c21b84a

Please sign in to comment.