From 573b7ed0a56a91acbe14f9434701957de0351f93 Mon Sep 17 00:00:00 2001 From: Charlotte Allen Date: Mon, 27 Jan 2020 16:35:03 -0800 Subject: [PATCH] Run files through formater --- env/dev/clj/shapey_shifty/dev_middleware.clj | 6 +-- env/dev/clj/shapey_shifty/env.clj | 6 +-- env/dev/clj/user.clj | 16 +++---- src/clj/shapey_shifty/config.clj | 14 +++---- src/clj/shapey_shifty/core.clj | 37 ++++++++-------- src/clj/shapey_shifty/db/core.clj | 21 +++++----- src/clj/shapey_shifty/handler.clj | 44 ++++++++++---------- src/clj/shapey_shifty/layout.clj | 30 ++++++------- src/clj/shapey_shifty/middleware.clj | 41 +++++++++--------- src/clj/shapey_shifty/middleware/formats.clj | 20 ++++----- src/clj/shapey_shifty/nrepl.clj | 4 +- test/clj/shapey_shifty/test/handler.clj | 12 +++--- 12 files changed, 123 insertions(+), 128 deletions(-) diff --git a/env/dev/clj/shapey_shifty/dev_middleware.clj b/env/dev/clj/shapey_shifty/dev_middleware.clj index 66b5aad..c6b4b49 100644 --- a/env/dev/clj/shapey_shifty/dev_middleware.clj +++ b/env/dev/clj/shapey_shifty/dev_middleware.clj @@ -1,8 +1,8 @@ (ns shapey-shifty.dev-middleware (:require - [ring.middleware.reload :refer [wrap-reload]] - [selmer.middleware :refer [wrap-error-page]] - [prone.middleware :refer [wrap-exceptions]])) + [ring.middleware.reload :refer [wrap-reload]] + [selmer.middleware :refer [wrap-error-page]] + [prone.middleware :refer [wrap-exceptions]])) (defn wrap-dev [handler] (-> handler diff --git a/env/dev/clj/shapey_shifty/env.clj b/env/dev/clj/shapey_shifty/env.clj index 252857a..0df7476 100644 --- a/env/dev/clj/shapey_shifty/env.clj +++ b/env/dev/clj/shapey_shifty/env.clj @@ -1,8 +1,8 @@ (ns shapey-shifty.env (:require - [selmer.parser :as parser] - [clojure.tools.logging :as log] - [shapey-shifty.dev-middleware :refer [wrap-dev]])) + [selmer.parser :as parser] + [clojure.tools.logging :as log] + [shapey-shifty.dev-middleware :refer [wrap-dev]])) (def defaults {:init diff --git a/env/dev/clj/user.clj b/env/dev/clj/user.clj index e9024d9..14c59a8 100644 --- a/env/dev/clj/user.clj +++ b/env/dev/clj/user.clj @@ -2,14 +2,14 @@ "Userspace functions you can run by default in your local REPL." (:require [shapey-shifty.config :refer [env]] - [clojure.pprint] - [clojure.spec.alpha :as s] - [expound.alpha :as expound] - [mount.core :as mount] - [shapey-shifty.core :refer [start-app]] - [shapey-shifty.db.core] - [conman.core :as conman] - [luminus-migrations.core :as migrations])) + [clojure.pprint] + [clojure.spec.alpha :as s] + [expound.alpha :as expound] + [mount.core :as mount] + [shapey-shifty.core :refer [start-app]] + [shapey-shifty.db.core] + [conman.core :as conman] + [luminus-migrations.core :as migrations])) (alter-var-root #'s/*explain-out* (constantly expound/printer)) diff --git a/src/clj/shapey_shifty/config.clj b/src/clj/shapey_shifty/config.clj index 53728f7..21cf278 100644 --- a/src/clj/shapey_shifty/config.clj +++ b/src/clj/shapey_shifty/config.clj @@ -1,13 +1,13 @@ (ns shapey-shifty.config (:require - [cprop.core :refer [load-config]] - [cprop.source :as source] - [mount.core :refer [args defstate]])) + [cprop.core :refer [load-config]] + [cprop.source :as source] + [mount.core :refer [args defstate]])) (defstate env :start (load-config - :merge - [(args) - (source/from-system-props) - (source/from-env)])) + :merge + [(args) + (source/from-system-props) + (source/from-env)])) diff --git a/src/clj/shapey_shifty/core.clj b/src/clj/shapey_shifty/core.clj index a32586c..69d45b7 100644 --- a/src/clj/shapey_shifty/core.clj +++ b/src/clj/shapey_shifty/core.clj @@ -1,22 +1,22 @@ (ns shapey-shifty.core (:require - [shapey-shifty.handler :as handler] - [shapey-shifty.nrepl :as nrepl] - [luminus.http-server :as http] - [luminus-migrations.core :as migrations] - [shapey-shifty.config :refer [env]] - [clojure.tools.cli :refer [parse-opts]] - [clojure.tools.logging :as log] - [mount.core :as mount]) + [shapey-shifty.handler :as handler] + [shapey-shifty.nrepl :as nrepl] + [luminus.http-server :as http] + [luminus-migrations.core :as migrations] + [shapey-shifty.config :refer [env]] + [clojure.tools.cli :refer [parse-opts]] + [clojure.tools.logging :as log] + [mount.core :as mount]) (:gen-class)) ;; log uncaught exceptions in threads (Thread/setDefaultUncaughtExceptionHandler - (reify Thread$UncaughtExceptionHandler - (uncaughtException [_ thread ex] - (log/error {:what :uncaught-exception - :exception ex - :where (str "Uncaught exception on" (.getName thread))})))) + (reify Thread$UncaughtExceptionHandler + (uncaughtException [_ thread ex] + (log/error {:what :uncaught-exception + :exception ex + :where (str "Uncaught exception on" (.getName thread))})))) (def cli-options [["-p" "--port PORT" "Port number" @@ -25,10 +25,10 @@ (mount/defstate ^{:on-reload :noop} http-server :start (http/start - (-> env - (assoc :handler (handler/app)) - (update :io-threads #(or % (* 2 (.availableProcessors (Runtime/getRuntime))))) - (update :port #(or (-> env :options :port) %)))) + (-> env + (assoc :handler (handler/app)) + (update :io-threads #(or % (* 2 (.availableProcessors (Runtime/getRuntime))))) + (update :port #(or (-> env :options :port) %)))) :stop (http/stop http-server)) @@ -41,7 +41,6 @@ (when repl-server (nrepl/stop repl-server))) - (defn stop-app [] (doseq [component (:stopped (mount/stop))] (log/info component "stopped")) @@ -72,4 +71,4 @@ (System/exit 0)) :else (start-app args))) - + diff --git a/src/clj/shapey_shifty/db/core.clj b/src/clj/shapey_shifty/db/core.clj index d23ab66..8cac63b 100644 --- a/src/clj/shapey_shifty/db/core.clj +++ b/src/clj/shapey_shifty/db/core.clj @@ -1,13 +1,13 @@ (ns shapey-shifty.db.core (:require - [cheshire.core :refer [generate-string parse-string]] - [clojure.java.jdbc :as jdbc] - [clojure.tools.logging :as log] - [conman.core :as conman] - [java-time :as jt] - [java-time.pre-java8] - [shapey-shifty.config :refer [env]] - [mount.core :refer [defstate]]) + [cheshire.core :refer [generate-string parse-string]] + [clojure.java.jdbc :as jdbc] + [clojure.tools.logging :as log] + [conman.core :as conman] + [java-time :as jt] + [java-time.pre-java8] + [shapey-shifty.config :refer [env]] + [mount.core :refer [defstate]]) (:import org.postgresql.util.PGobject java.sql.Array clojure.lang.IPersistentMap @@ -25,9 +25,8 @@ (conman/bind-connection *db* "sql/queries.sql") - (extend-protocol jdbc/IResultSetReadColumn - java.sql.Timestamp + java.sql.Timestamp (result-set-read-column [v _2 _3] (.toLocalDateTime v)) java.sql.Date @@ -64,7 +63,7 @@ (.setObject stmt idx (to-pg-json v)))))) (extend-protocol jdbc/ISQLValue - java.util.Date + java.util.Date (sql-value [v] (java.sql.Timestamp. (.getTime v))) java.time.LocalTime diff --git a/src/clj/shapey_shifty/handler.clj b/src/clj/shapey_shifty/handler.clj index f055f62..102f8e5 100644 --- a/src/clj/shapey_shifty/handler.clj +++ b/src/clj/shapey_shifty/handler.clj @@ -1,13 +1,13 @@ (ns shapey-shifty.handler (:require - [shapey-shifty.middleware :as middleware] - [shapey-shifty.layout :refer [error-page]] - [shapey-shifty.routes.home :refer [home-routes]] - [reitit.ring :as ring] - [ring.middleware.content-type :refer [wrap-content-type]] - [ring.middleware.webjars :refer [wrap-webjars]] - [shapey-shifty.env :refer [defaults]] - [mount.core :as mount])) + [shapey-shifty.middleware :as middleware] + [shapey-shifty.layout :refer [error-page]] + [shapey-shifty.routes.home :refer [home-routes]] + [reitit.ring :as ring] + [ring.middleware.content-type :refer [wrap-content-type]] + [ring.middleware.webjars :refer [wrap-webjars]] + [shapey-shifty.env :refer [defaults]] + [mount.core :as mount])) (mount/defstate init-app :start ((or (:init defaults) (fn []))) @@ -16,20 +16,20 @@ (mount/defstate app-routes :start (ring/ring-handler - (ring/router - [(home-routes)]) - (ring/routes - (ring/create-resource-handler - {:path "/"}) - (wrap-content-type - (wrap-webjars (constantly nil))) - (ring/create-default-handler - {:not-found - (constantly (error-page {:status 404, :title "404 - Page not found"})) - :method-not-allowed - (constantly (error-page {:status 405, :title "405 - Not allowed"})) - :not-acceptable - (constantly (error-page {:status 406, :title "406 - Not acceptable"}))})))) + (ring/router + [(home-routes)]) + (ring/routes + (ring/create-resource-handler + {:path "/"}) + (wrap-content-type + (wrap-webjars (constantly nil))) + (ring/create-default-handler + {:not-found + (constantly (error-page {:status 404, :title "404 - Page not found"})) + :method-not-allowed + (constantly (error-page {:status 405, :title "405 - Not allowed"})) + :not-acceptable + (constantly (error-page {:status 406, :title "406 - Not acceptable"}))})))) (defn app [] (middleware/wrap-base #'app-routes)) diff --git a/src/clj/shapey_shifty/layout.clj b/src/clj/shapey_shifty/layout.clj index 78c67f0..8b8b5d7 100644 --- a/src/clj/shapey_shifty/layout.clj +++ b/src/clj/shapey_shifty/layout.clj @@ -1,13 +1,13 @@ (ns shapey-shifty.layout (:require - [clojure.java.io] - [selmer.parser :as parser] - [selmer.filters :as filters] - [markdown.core :refer [md-to-html-string]] - [ring.util.http-response :refer [content-type ok]] - [ring.util.anti-forgery :refer [anti-forgery-field]] - [ring.middleware.anti-forgery :refer [*anti-forgery-token*]] - [ring.util.response])) + [clojure.java.io] + [selmer.parser :as parser] + [selmer.filters :as filters] + [markdown.core :refer [md-to-html-string]] + [ring.util.http-response :refer [content-type ok]] + [ring.util.anti-forgery :refer [anti-forgery-field]] + [ring.middleware.anti-forgery :refer [*anti-forgery-token*]] + [ring.util.response])) (parser/set-resource-path! (clojure.java.io/resource "html")) (parser/add-tag! :csrf-field (fn [_ _] (anti-forgery-field))) @@ -17,13 +17,13 @@ "renders the HTML template located relative to resources/html" [request template & [params]] (content-type - (ok - (parser/render-file - template - (assoc params - :page template - :csrf-token *anti-forgery-token*))) - "text/html; charset=utf-8")) + (ok + (parser/render-file + template + (assoc params + :page template + :csrf-token *anti-forgery-token*))) + "text/html; charset=utf-8")) (defn error-page "error-details should be a map containing the following keys: diff --git a/src/clj/shapey_shifty/middleware.clj b/src/clj/shapey_shifty/middleware.clj index 0f562b4..2b966ad 100644 --- a/src/clj/shapey_shifty/middleware.clj +++ b/src/clj/shapey_shifty/middleware.clj @@ -1,18 +1,16 @@ (ns shapey-shifty.middleware (:require - [shapey-shifty.env :refer [defaults]] - [cheshire.generate :as cheshire] - [cognitect.transit :as transit] - [clojure.tools.logging :as log] - [shapey-shifty.layout :refer [error-page]] - [ring.middleware.anti-forgery :refer [wrap-anti-forgery]] - [shapey-shifty.middleware.formats :as formats] - [muuntaja.middleware :refer [wrap-format wrap-params]] - [shapey-shifty.config :refer [env]] - [ring-ttl-session.core :refer [ttl-memory-store]] - [ring.middleware.defaults :refer [site-defaults wrap-defaults]]) - - ) + [shapey-shifty.env :refer [defaults]] + [cheshire.generate :as cheshire] + [cognitect.transit :as transit] + [clojure.tools.logging :as log] + [shapey-shifty.layout :refer [error-page]] + [ring.middleware.anti-forgery :refer [wrap-anti-forgery]] + [shapey-shifty.middleware.formats :as formats] + [muuntaja.middleware :refer [wrap-format wrap-params]] + [shapey-shifty.config :refer [env]] + [ring-ttl-session.core :refer [ttl-memory-store]] + [ring.middleware.defaults :refer [site-defaults wrap-defaults]])) (defn wrap-internal-error [handler] (fn [req] @@ -26,12 +24,11 @@ (defn wrap-csrf [handler] (wrap-anti-forgery - handler - {:error-response - (error-page - {:status 403 - :title "Invalid anti-forgery token"})})) - + handler + {:error-response + (error-page + {:status 403 + :title "Invalid anti-forgery token"})})) (defn wrap-formats [handler] (let [wrapped (-> handler wrap-params (wrap-format formats/instance))] @@ -43,7 +40,7 @@ (defn wrap-base [handler] (-> ((:middleware defaults) handler) (wrap-defaults - (-> site-defaults - (assoc-in [:security :anti-forgery] false) - (assoc-in [:session :store] (ttl-memory-store (* 60 30))))) + (-> site-defaults + (assoc-in [:security :anti-forgery] false) + (assoc-in [:session :store] (ttl-memory-store (* 60 30))))) wrap-internal-error)) diff --git a/src/clj/shapey_shifty/middleware/formats.clj b/src/clj/shapey_shifty/middleware/formats.clj index 42ab67b..6aa546d 100644 --- a/src/clj/shapey_shifty/middleware/formats.clj +++ b/src/clj/shapey_shifty/middleware/formats.clj @@ -1,15 +1,15 @@ (ns shapey-shifty.middleware.formats (:require - [cognitect.transit :as transit] - [luminus-transit.time :as time] - [muuntaja.core :as m])) + [cognitect.transit :as transit] + [luminus-transit.time :as time] + [muuntaja.core :as m])) (def instance (m/create - (-> m/default-options - (update-in - [:formats "application/transit+json" :decoder-opts] - (partial merge time/time-deserialization-handlers)) - (update-in - [:formats "application/transit+json" :encoder-opts] - (partial merge time/time-serialization-handlers))))) + (-> m/default-options + (update-in + [:formats "application/transit+json" :decoder-opts] + (partial merge time/time-deserialization-handlers)) + (update-in + [:formats "application/transit+json" :encoder-opts] + (partial merge time/time-serialization-handlers))))) diff --git a/src/clj/shapey_shifty/nrepl.clj b/src/clj/shapey_shifty/nrepl.clj index 8dda084..681193f 100644 --- a/src/clj/shapey_shifty/nrepl.clj +++ b/src/clj/shapey_shifty/nrepl.clj @@ -1,7 +1,7 @@ (ns shapey-shifty.nrepl (:require - [nrepl.server :as nrepl] - [clojure.tools.logging :as log])) + [nrepl.server :as nrepl] + [clojure.tools.logging :as log])) (defn start "Start a network repl for debugging on specified port followed by diff --git a/test/clj/shapey_shifty/test/handler.clj b/test/clj/shapey_shifty/test/handler.clj index 02506e3..5ad5737 100644 --- a/test/clj/shapey_shifty/test/handler.clj +++ b/test/clj/shapey_shifty/test/handler.clj @@ -1,11 +1,11 @@ (ns shapey-shifty.test.handler (:require - [clojure.test :refer :all] - [ring.mock.request :refer :all] - [shapey-shifty.handler :refer :all] - [shapey-shifty.middleware.formats :as formats] - [muuntaja.core :as m] - [mount.core :as mount])) + [clojure.test :refer :all] + [ring.mock.request :refer :all] + [shapey-shifty.handler :refer :all] + [shapey-shifty.middleware.formats :as formats] + [muuntaja.core :as m] + [mount.core :as mount])) (defn parse-json [body] (m/decode formats/instance "application/json" body))