Skip to content

Commit 3ef0481

Browse files
committed
Fix inconsistent formatting with cljfmt
1 parent a66fe9e commit 3ef0481

File tree

26 files changed

+255
-259
lines changed

26 files changed

+255
-259
lines changed

ring-core/src/ring/middleware/cookies.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
(for [[key value] cookies]
124124
(if (map? value)
125125
(apply str (write-value key (:value value) encoder)
126-
(write-attr-map (dissoc value :value)))
126+
(write-attr-map (dissoc value :value)))
127127
(write-value key value encoder))))
128128

129129
(defn- set-cookies [response encoder]

ring-core/src/ring/middleware/multipart_params/temp_file.clj

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
(defmacro ^{:private true} do-every [delay & body]
1212
`(background-thread
13-
#(while true
14-
(Thread/sleep ~(with-meta `(* ~delay 1000) {:tag 'long}))
15-
(try ~@body
16-
(catch Exception ex#)))))
13+
#(while true
14+
(Thread/sleep ~(with-meta `(* ~delay 1000) {:tag 'long}))
15+
(try ~@body
16+
(catch Exception ex#)))))
1717

1818
(defn- expired? [^File file expiry-time]
1919
(< (.lastModified file)
@@ -34,14 +34,14 @@
3434
(defn- start-clean-up [file-set expires-in]
3535
(when expires-in
3636
(do-every expires-in
37-
(remove-old-files file-set expires-in))))
37+
(remove-old-files file-set expires-in))))
3838

3939
(defn- ensure-shutdown-clean-up [file-set]
4040
(.addShutdownHook
41-
(Runtime/getRuntime)
42-
(Thread.
43-
#(doseq [^File file @file-set]
44-
(.delete file)))))
41+
(Runtime/getRuntime)
42+
(Thread.
43+
#(doseq [^File file @file-set]
44+
(.delete file)))))
4545

4646
(defn temp-file-store
4747
"Returns a function that stores multipart file parameters as temporary files.
@@ -60,13 +60,13 @@
6060
{:arglists '([] [options])}
6161
([] (temp-file-store {:expires-in 3600}))
6262
([{:keys [expires-in]}]
63-
(let [file-set (atom #{})
64-
clean-up (delay (start-clean-up file-set expires-in))]
65-
(ensure-shutdown-clean-up file-set)
66-
(fn [item]
67-
(force clean-up)
68-
(let [temp-file (make-temp-file file-set)]
69-
(io/copy (:stream item) temp-file)
70-
(-> (select-keys item [:filename :content-type])
71-
(assoc :tempfile temp-file
72-
:size (.length temp-file))))))))
63+
(let [file-set (atom #{})
64+
clean-up (delay (start-clean-up file-set expires-in))]
65+
(ensure-shutdown-clean-up file-set)
66+
(fn [item]
67+
(force clean-up)
68+
(let [temp-file (make-temp-file file-set)]
69+
(io/copy (:stream item) temp-file)
70+
(-> (select-keys item [:filename :content-type])
71+
(assoc :tempfile temp-file
72+
:size (.length temp-file))))))))

ring-core/src/ring/middleware/nested_params.clj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@
3838
"Return a list of name-value pairs for a parameter map."
3939
[params]
4040
(mapcat
41-
(fn [[name value]]
42-
(if (and (sequential? value) (not (coll? (first value))))
43-
(for [v value] [name v])
44-
[[name value]]))
45-
params))
41+
(fn [[name value]]
42+
(if (and (sequential? value) (not (coll? (first value))))
43+
(for [v value] [name v])
44+
[[name value]]))
45+
params))
4646

4747
(defn- nest-params
4848
"Takes a flat map of parameters and turns it into a nested map of
4949
parameters, using the function parse to split the parameter names
5050
into keys."
5151
[params parse]
5252
(reduce
53-
(fn [m [k v]]
54-
(assoc-nested m (parse k) v))
55-
{}
56-
(param-pairs params)))
53+
(fn [m [k v]]
54+
(assoc-nested m (parse k) v))
55+
{}
56+
(param-pairs params)))
5757

5858
(defn nested-params-request
5959
"Converts a request with a flat map of parameters to a nested map.

ring-core/src/ring/middleware/session.clj

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
(defn- bare-session-response
4545
[response {session-key :session/key} {:keys [store cookie-name cookie-attrs]}]
4646
(let [new-session-key (if (contains? response :session)
47-
(if-let [session (response :session)]
47+
(if-let [session (response :session)]
4848
(if (:recreate (meta session))
4949
(do
5050
(store/delete-session store session-key)
@@ -103,17 +103,17 @@
103103
:set-cookies? - If true, automatically include cookie middleware. Defaults to
104104
true for backward compatibility."
105105
([handler]
106-
(wrap-session handler {}))
106+
(wrap-session handler {}))
107107
([handler options]
108-
(let [options (session-options options)]
109-
(fn
110-
([request]
111-
(let [request (session-request request options)]
112-
(-> (handler request)
113-
(session-response request options))))
114-
([request respond raise]
115-
(let [request (session-request request options)]
116-
(handler request
117-
(fn [response]
118-
(respond (session-response response request options)))
119-
raise)))))))
108+
(let [options (session-options options)]
109+
(fn
110+
([request]
111+
(let [request (session-request request options)]
112+
(-> (handler request)
113+
(session-response request options))))
114+
([request respond raise]
115+
(let [request (session-request request options)]
116+
(handler request
117+
(fn [response]
118+
(respond (session-response response request options)))
119+
raise)))))))

ring-core/src/ring/middleware/session/cookie.clj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
iv (random/bytes (.getBlockSize cipher))]
4343
(.init cipher Cipher/ENCRYPT_MODE secret-key (IvParameterSpec. iv))
4444
(->> (.doFinal cipher data)
45-
(concat iv)
46-
(byte-array))))
45+
(concat iv)
46+
(byte-array))))
4747

4848
(defn- decrypt
4949
"Decrypt an array of bytes with a key."
@@ -121,6 +121,6 @@
121121
clojure.core/print-method or clojure.core/print-dup multimethods."
122122
([] (cookie-store {}))
123123
([options]
124-
(let [key (get-secret-key options)]
125-
(assert (valid-secret-key? key) "the secret key must be exactly 16 bytes")
126-
(CookieStore. key options))))
124+
(let [key (get-secret-key options)]
125+
(assert (valid-secret-key? key) "the secret key must be exactly 16 bytes")
126+
(CookieStore. key options))))

ring-core/src/ring/util/io.clj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"Utility functions for handling I/O."
33
(:require [clojure.java.io :as io])
44
(:import [java.io PipedInputStream
5-
PipedOutputStream
6-
ByteArrayInputStream
7-
File
8-
Closeable
9-
IOException]))
5+
PipedOutputStream
6+
ByteArrayInputStream
7+
File
8+
Closeable
9+
IOException]))
1010

1111
(defn piped-input-stream
1212
"Create an input stream from a function that takes an output stream as its
@@ -33,9 +33,9 @@
3333
"Returns a ByteArrayInputStream for the given String."
3434
{:added "1.1"}
3535
([^String s]
36-
(ByteArrayInputStream. (.getBytes s)))
36+
(ByteArrayInputStream. (.getBytes s)))
3737
([^String s ^String encoding]
38-
(ByteArrayInputStream. (.getBytes s encoding))))
38+
(ByteArrayInputStream. (.getBytes s encoding))))
3939

4040
(defn close!
4141
"Ensure a stream is closed, swallowing any exceptions."

ring-core/src/ring/util/mime_type.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
"Get the mimetype from the filename extension. Takes an optional map of
112112
extensions to mimetypes that overrides values in the default-mime-types map."
113113
([filename]
114-
(ext-mime-type filename {}))
114+
(ext-mime-type filename {}))
115115
([filename mime-types]
116-
(let [mime-types (merge default-mime-types mime-types)]
117-
(mime-types (filename-ext filename)))))
116+
(let [mime-types (merge default-mime-types mime-types)]
117+
(mime-types (filename-ext filename)))))

ring-core/src/ring/util/request.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@
8181
[request ^String context]
8282
{:pre [(in-context? request context)]}
8383
(assoc request
84-
:context context
85-
:path-info (subs (:uri request) (.length context))))
84+
:context context
85+
:path-info (subs (:uri request) (.length context))))

ring-core/src/ring/util/response.clj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
{:added "1.2"}
4141
([url] (created url nil))
4242
([url body]
43-
{:status 201
44-
:headers {"Location" url}
45-
:body body}))
43+
{:status 201
44+
:headers {"Location" url}
45+
:body body}))
4646

4747
(defn bad-request
4848
"Returns a 400 'bad request' response."
@@ -126,9 +126,9 @@
126126
(if-let [^File file (safely-find-file path opts)]
127127
(cond
128128
(.isDirectory file)
129-
(and (:index-files? opts true) (find-index-file file))
129+
(and (:index-files? opts true) (find-index-file file))
130130
(.exists file)
131-
file)))
131+
file)))
132132

133133
(defn- file-data [^File file]
134134
{:content file
@@ -214,10 +214,10 @@
214214
{:added "1.1"}
215215
[resp charset]
216216
(update-header resp "Content-Type"
217-
(fn [content-type]
218-
(-> (or content-type "text/plain")
219-
(str/replace #";\s*charset=[^;]*" "")
220-
(str "; charset=" charset)))))
217+
(fn [content-type]
218+
(-> (or content-type "text/plain")
219+
(str/replace #";\s*charset=[^;]*" "")
220+
(str "; charset=" charset)))))
221221

222222
(defn get-charset
223223
"Gets the character encoding of a Ring response."

ring-core/test/ring/middleware/test/content_type.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@
6969
(deftest content-type-response-test
7070
(testing "function exists"
7171
(is (fn? content-type-response)))
72-
72+
7373
(testing "nil response"
7474
(is (nil? (content-type-response nil {})))))

ring-core/test/ring/middleware/test/cookies.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
(update-in headers ["Set-Cookie"] split-header)))
5252

5353
(deftest wrap-cookies-set-extra-attrs
54-
(let [cookies {"a" {:value "b", :path "/", :secure true, :http-only true }}
54+
(let [cookies {"a" {:value "b", :path "/", :secure true, :http-only true}}
5555
handler (constantly {:cookies cookies})
5656
resp ((wrap-cookies handler) {})]
5757
(is (= {"Set-Cookie" #{"a=b" "Path=/" "Secure" "HttpOnly"}}
@@ -230,7 +230,7 @@
230230
resp ((wrap-cookies handler) {})
231231
expires "Thu, 31 Dec 2015 00:00:00 GMT"]
232232
(is (= {"Set-Cookie" #{"a=b" "Path=/" "Secure" "HttpOnly" (str "Expires=" expires)}}
233-
(split-set-cookie (:headers resp)))))
233+
(split-set-cookie (:headers resp)))))
234234
(finally
235235
(java.util.Locale/setDefault default-locale)))))
236236

ring-core/test/ring/middleware/test/file_info.clj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111
(def unknown-file (File. "test/ring/assets/random.xyz"))
1212
(def unknown-file-app (wrap-file-info (constantly {:headers {} :body unknown-file})))
1313

14-
(defmacro with-last-modified
14+
(defmacro with-last-modified
1515
"Lets us use a known file modification time for tests, without permanently changing
1616
the file's modification time."
1717
[[file new-time] form]
18-
`(let [old-time# (.lastModified ~file)]
18+
`(let [old-time# (.lastModified ~file)]
1919
(.setLastModified ~file ~(* new-time 1000))
2020
(try ~form
2121
(finally (.setLastModified ~file old-time#)))))
2222

2323
(def custom-type-app
2424
(wrap-file-info
25-
(constantly {:headers {} :body known-file})
26-
{"txt" "custom/type"}))
25+
(constantly {:headers {} :body known-file})
26+
{"txt" "custom/type"}))
2727

2828
(deftest wrap-file-info-non-file-response
2929
(is (= {:headers {} :body "body"} (non-file-app {}))))
@@ -60,7 +60,7 @@
6060
"Last-Modified" "Thu, 14 Jan 2010 22:00:00 +0000"}
6161
:body ""}
6262
(known-file-app
63-
{:headers {"if-modified-since" "Thu, 14 Jan 2010 22:00:00 +0000" }})))))
63+
{:headers {"if-modified-since" "Thu, 14 Jan 2010 22:00:00 +0000"}})))))
6464

6565
(deftest wrap-file-info-if-modified-miss
6666
(with-last-modified [known-file 1263506400]
@@ -69,7 +69,7 @@
6969
"Last-Modified" "Thu, 14 Jan 2010 22:00:00 +0000"}
7070
:body known-file}
7171
(known-file-app
72-
{:headers {"if-modified-since" "Wed, 13 Jan 2010 22:00:00 +0000"}})))))
72+
{:headers {"if-modified-since" "Wed, 13 Jan 2010 22:00:00 +0000"}})))))
7373

7474
(deftest wrap-file-info-cps-test
7575
(testing "file response"
@@ -85,7 +85,7 @@
8585
:body known-file}
8686
@response))
8787
(is (not (realized? exception))))))
88-
88+
8989
(testing "non-file response"
9090
(let [handler (wrap-file-info
9191
(fn [_ respond _] (respond {:headers {} :body "body"})))

ring-core/test/ring/middleware/test/flash.clj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
(deftest flash-is-retrieved-from-session
1212
(let [message {:error "Could not save"}
1313
handler (wrap-flash
14-
(fn [request]
15-
(is (= (:flash request) message))
16-
{}))]
14+
(fn [request]
15+
(is (= (:flash request) message))
16+
{}))]
1717
(handler {:session {:_flash message}})))
1818

1919
(deftest flash-is-removed-after-read

ring-core/test/ring/middleware/test/multipart_params.clj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@
8888
:body (string-input-stream form-body "UTF-8")}
8989
response (promise)
9090
exception (promise)]
91-
(handler request response exception)
92-
(is (= (get-in @response [:multipart-params "foo"]) "bar"))
93-
(is (not (realized? exception)))))
91+
(handler request response exception)
92+
(is (= (get-in @response [:multipart-params "foo"]) "bar"))
93+
(is (not (realized? exception)))))
9494

9595
(deftest multipart-params-request-test
9696
(is (fn? multipart-params-request)))
@@ -105,7 +105,7 @@
105105
(str "multipart/form-data; boundary=XXXX")}
106106
:body (string-input-stream form-body "UTF-8")}
107107
request* (multipart-params-request request)]
108-
(is (= (get-in request* [:multipart-params "foo"]) "Øæß箣èé"))))
108+
(is (= (get-in request* [:multipart-params "foo"]) "Øæß箣èé"))))
109109

110110
(deftest parts-may-have-invidual-charsets-in-content-type
111111
(let [form-body (str "--XXXX\r\n"

ring-core/test/ring/middleware/test/resource.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
no-loader (wrap-resource test-handler "/ring/assets")
3434
with-loader (wrap-resource test-handler "/ring/assets" {:loader loader})]
3535
(are [request body] (= (slurp (:body (no-loader request))) body)
36-
{:request-method :get, :uri "/foo.html"} "foo")
36+
{:request-method :get, :uri "/foo.html"} "foo")
3737
(are [request body] (= (slurp (:body (with-loader request))) body)
3838
{:request-method :get, :uri "/foo.html"} "foo-in-jar")
3939
(testing "does accept trailing slash in asset path"

0 commit comments

Comments
 (0)