Skip to content

Commit d7d0378

Browse files
committed
Fix clj-kondo warnings in src directories
1 parent 3ef0481 commit d7d0378

File tree

21 files changed

+72
-69
lines changed

21 files changed

+72
-69
lines changed

.clj-kondo/config.edn

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{:lint-as {hiccup.def/defhtml clojure.core/defn}
2+
:linters
3+
{:deprecated-var
4+
{:exclude
5+
{ring.middleware.file-info/file-info-response
6+
{:defs [ring.middleware.file-info/wrap-file-info]
7+
:namespaces [ring.middleware.test.file-info]}}}}}

ring-core-protocols/src/ring/core/protocols.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
(io/writer output-stream)))
3838

3939
(extend-protocol StreamableResponseBody
40-
(Class/forName "[B")
40+
#_{:clj-kondo/ignore [:syntax]} (Class/forName "[B")
4141
(write-body-to-stream [body _ ^OutputStream output-stream]
4242
(.write output-stream ^bytes body)
4343
(.close output-stream))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
([response request]
1515
(content-type-response response request {}))
1616
([response request options]
17-
(if response
17+
(when response
1818
(if (get-header response "Content-Type")
1919
response
2020
(let [mime-type (guess-mime-type request response (:mime-types options))]

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"Ensures that a directory exists at the given path, throwing if one does not."
1414
[dir-path]
1515
(let [dir (io/as-file dir-path)]
16-
(if-not (.exists dir)
16+
(when-not (.exists dir)
1717
(throw (Exception. (format "Directory does not exist: %s" dir-path))))))
1818

1919
(defn file-request
@@ -27,7 +27,7 @@
2727
:index-files? true
2828
:allow-symlinks? false}
2929
options)]
30-
(if (#{:get :head} (:request-method request))
30+
(when (#{:get :head} (:request-method request))
3131
(let [path (subs (codec/url-decode (request/path-info request)) 1)]
3232
(-> (response/file-response path options)
3333
(head/head-response request)))))))

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[ring.util.mime-type :refer [ext-mime-type]]
88
[ring.util.io :refer [last-modified-date]])
99
(:import [java.io File]
10-
[java.util Date Locale TimeZone]
10+
[java.util Locale TimeZone]
1111
[java.text SimpleDateFormat]))
1212

1313
(defn- guess-mime-type
@@ -17,17 +17,17 @@
1717
(or (ext-mime-type (.getPath file) mime-types)
1818
"application/octet-stream"))
1919

20-
(defn- ^SimpleDateFormat make-http-format
20+
(defn- make-http-format
2121
"Formats or parses dates into HTTP date format (RFC 822/1123)."
22-
[]
22+
^SimpleDateFormat []
2323
;; SimpleDateFormat is not threadsafe, so return a new instance each time
2424
(doto (SimpleDateFormat. "EEE, dd MMM yyyy HH:mm:ss ZZZ" Locale/US)
2525
(.setTimeZone (TimeZone/getTimeZone "UTC"))))
2626

2727
(defn- not-modified-since?
2828
"Has the file been modified since the last request from the client?"
29-
[{headers :headers :as req} last-modified]
30-
(if-let [modified-since (headers "if-modified-since")]
29+
[{headers :headers} last-modified]
30+
(when-let [modified-since (headers "if-modified-since")]
3131
(not (.before (.parse (make-http-format) modified-since)
3232
last-modified))))
3333

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{:added "1.2"}
1818
[response request]
1919
(let [{:keys [session flash]} request]
20-
(if response
20+
(when response
2121
(let [session (if (contains? response :session)
2222
(response :session)
2323
session)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
(defn- keyword-syntax?
1111
[s parse-namespaces?]
1212
(or (re-matches re-plain-keyword s)
13-
(if parse-namespaces? (re-matches re-namespaced-keyword s))))
13+
(when parse-namespaces? (re-matches re-namespaced-keyword s))))
1414

1515
(defn- keyify-params [target parse-namespaces?]
1616
(cond

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
(.delete file)
2727
(swap! file-set disj file))))
2828

29-
(defn- ^File make-temp-file [file-set]
29+
(defn- make-temp-file ^File [file-set]
3030
(let [temp-file (File/createTempFile "ring-multipart-" nil)]
3131
(swap! file-set conj temp-file)
3232
temp-file))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
=> [\"foo\" \"bar\" \"\" \"baz\"]"
1313
[param-name]
1414
(let [[_ k ks] (re-matches #"(?s)(.*?)((?:\[.*?\])*)" (name param-name))
15-
keys (if ks (map second (re-seq #"\[(.*?)\]" ks)))]
15+
keys (when ks (map second (re-seq #"\[(.*?)\]" ks)))]
1616
(cons k keys)))
1717

1818
(defn- assoc-vec [m k v]

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"Middleware that returns a 304 Not Modified response for responses with
33
Last-Modified headers."
44
(:require [ring.util.time :refer [parse-date]]
5-
[ring.util.response :refer [status get-header header]]
5+
[ring.util.response :refer [get-header header]]
66
[ring.util.io :refer [close!]]))
77

88
(defn- etag-match? [request response]
9-
(if-let [etag (get-header response "ETag")]
9+
(when-let [etag (get-header response "ETag")]
1010
(= etag (get-header request "if-none-match"))))
1111

12-
(defn- ^java.util.Date date-header [response header]
13-
(if-let [http-date (get-header response header)]
12+
(defn- date-header ^java.util.Date [response header]
13+
(when-let [http-date (get-header response header)]
1414
(parse-date http-date)))
1515

1616
(defn- not-modified-since? [request response]

0 commit comments

Comments
 (0)