Skip to content

Commit 5282c0f

Browse files
committed
lint cleanup
1 parent 24144bc commit 5282c0f

17 files changed

+190
-186
lines changed

.clj-kondo/config.edn

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{:skip-comments true
2+
:linters
3+
{:unused-binding {:level :off}
4+
:cond-else {:level :off}
5+
:refer-all {:level :off}
6+
:deprecated-var {:level :off}}}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ tests.js
2020
tests.js.map
2121
pom.xml.versionsBackup
2222
.cpcache/
23+
.clj-kondo/.cache

build.clj

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
clojure.core.async.impl.concurrent
1717
clojure.core.async.impl.dispatch
1818
clojure.core.async.impl.ioc-macros
19-
clojure.core.async.impl.ioc-alt
2019
clojure.core.async.impl.buffers
2120
clojure.core.async.impl.channels
2221
clojure.core.async.impl.timers

deps.edn

+5
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,9 @@
1010
:build
1111
{:deps {io.github.clojure/tools.build {:tag "v0.6.6" :sha "4d41c26"}}
1212
:ns-default build}
13+
14+
;; Lint the source
15+
;; clj -M:lint
16+
:lint {:replace-deps {clj-kondo/clj-kondo {:mvn/version "2022.01.13"}}
17+
:main-opts ["-m" "clj-kondo.main" "--lint" "src"]}
1318
}}

src/main/clojure/clojure/core/async.clj

+17-16
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ to catch and handle."
3030
[clojure.core.async.impl.mutex :as mutex]
3131
[clojure.core.async.impl.concurrent :as conc]
3232
)
33-
(:import [java.util.concurrent.locks Lock]
33+
(:import [java.util.concurrent.atomic AtomicLong]
34+
[java.util.concurrent.locks Lock]
3435
[java.util.concurrent Executors Executor ThreadLocalRandom]
35-
[java.util ArrayList]))
36+
[java.util Arrays ArrayList]
37+
[clojure.lang Var]))
3638

3739
(alias 'core 'clojure.core)
3840

@@ -222,7 +224,7 @@ to catch and handle."
222224
[chan]
223225
(impl/close! chan))
224226

225-
(defonce ^:private ^java.util.concurrent.atomic.AtomicLong id-gen (java.util.concurrent.atomic.AtomicLong.))
227+
(defonce ^:private ^AtomicLong id-gen (AtomicLong.))
226228

227229
(defn- random-array
228230
[n]
@@ -231,11 +233,10 @@ to catch and handle."
231233
(loop [i 1]
232234
(if (= i n)
233235
a
234-
(do
235-
(let [j (.nextInt rand (inc i))]
236-
(aset a i (aget a j))
237-
(aset a j i)
238-
(recur (inc i))))))))
236+
(let [j (.nextInt rand (inc i))]
237+
(aset a i (aget a j))
238+
(aset a j i)
239+
(recur (inc i)))))))
239240

240241
(defn- alt-flag []
241242
(let [^Lock m (mutex/mutex)
@@ -456,7 +457,7 @@ to catch and handle."
456457
[& body]
457458
(let [crossing-env (zipmap (keys &env) (repeatedly gensym))]
458459
`(let [c# (chan 1)
459-
captured-bindings# (clojure.lang.Var/getThreadBindingFrame)]
460+
captured-bindings# (Var/getThreadBindingFrame)]
460461
(dispatch/run
461462
(^:once fn* []
462463
(let [~@(mapcat (fn [[l sym]] [sym `(^:once fn* [] ~(vary-meta l dissoc :tag))]) crossing-env)
@@ -476,10 +477,10 @@ to catch and handle."
476477
f when completed, then close."
477478
[f]
478479
(let [c (chan 1)]
479-
(let [binds (clojure.lang.Var/getThreadBindingFrame)]
480+
(let [binds (Var/getThreadBindingFrame)]
480481
(.execute thread-macro-executor
481482
(fn []
482-
(clojure.lang.Var/resetThreadBindingFrame binds)
483+
(Var/resetThreadBindingFrame binds)
483484
(try
484485
(let [ret (f)]
485486
(when-not (nil? ret)
@@ -852,7 +853,7 @@ to catch and handle."
852853
{:solos solos
853854
:mutes (pick :mute chs)
854855
:reads (conj
855-
(if (and (= mode :pause) (not (empty? solos)))
856+
(if (and (= mode :pause) (seq solos))
856857
(vec solos)
857858
(vec (remove pauses (keys chs))))
858859
change)}))
@@ -952,10 +953,10 @@ to catch and handle."
952953
(muxch* [_] ch)
953954

954955
Pub
955-
(sub* [p topic ch close?]
956+
(sub* [_p topic ch close?]
956957
(let [m (ensure-mult topic)]
957958
(tap m ch close?)))
958-
(unsub* [p topic ch]
959+
(unsub* [_p topic ch]
959960
(when-let [m (get @mults topic)]
960961
(untap m ch)))
961962
(unsub-all* [_] (reset! mults {}))
@@ -1013,7 +1014,7 @@ to catch and handle."
10131014
(fn [ret]
10141015
(aset rets i ret)
10151016
(when (zero? (swap! dctr dec))
1016-
(put! dchan (java.util.Arrays/copyOf rets cnt)))))
1017+
(put! dchan (Arrays/copyOf rets cnt)))))
10171018
(range cnt))]
10181019
(if (zero? cnt)
10191020
(close! out)
@@ -1022,7 +1023,7 @@ to catch and handle."
10221023
(dotimes [i cnt]
10231024
(try
10241025
(take! (chs i) (done i))
1025-
(catch Exception e
1026+
(catch Exception _
10261027
(swap! dctr dec))))
10271028
(let [rets (<! dchan)]
10281029
(if (some nil? rets)

src/main/clojure/clojure/core/async/impl/buffers.clj

+18-17
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,23 @@
99
(ns ^{:skip-wiki true}
1010
clojure.core.async.impl.buffers
1111
(:require [clojure.core.async.impl.protocols :as impl])
12-
(:import [java.util LinkedList Queue]))
12+
(:import [java.util LinkedList]
13+
[clojure.lang Counted]))
1314

1415
(set! *warn-on-reflection* true)
1516

1617
(deftype FixedBuffer [^LinkedList buf ^long n]
1718
impl/Buffer
18-
(full? [this]
19+
(full? [_this]
1920
(>= (.size buf) n))
20-
(remove! [this]
21+
(remove! [_this]
2122
(.removeLast buf))
2223
(add!* [this itm]
2324
(.addFirst buf itm)
2425
this)
25-
(close-buf! [this])
26-
clojure.lang.Counted
27-
(count [this]
26+
(close-buf! [_this])
27+
Counted
28+
(count [_this]
2829
(.size buf)))
2930

3031
(defn fixed-buffer [^long n]
@@ -34,17 +35,17 @@
3435
(deftype DroppingBuffer [^LinkedList buf ^long n]
3536
impl/UnblockingBuffer
3637
impl/Buffer
37-
(full? [this]
38+
(full? [_this]
3839
false)
39-
(remove! [this]
40+
(remove! [_this]
4041
(.removeLast buf))
4142
(add!* [this itm]
4243
(when-not (>= (.size buf) n)
4344
(.addFirst buf itm))
4445
this)
45-
(close-buf! [this])
46-
clojure.lang.Counted
47-
(count [this]
46+
(close-buf! [_this])
47+
Counted
48+
(count [_this]
4849
(.size buf)))
4950

5051
(defn dropping-buffer [n]
@@ -53,18 +54,18 @@
5354
(deftype SlidingBuffer [^LinkedList buf ^long n]
5455
impl/UnblockingBuffer
5556
impl/Buffer
56-
(full? [this]
57+
(full? [_this]
5758
false)
58-
(remove! [this]
59+
(remove! [_this]
5960
(.removeLast buf))
6061
(add!* [this itm]
6162
(when (= (.size buf) n)
6263
(impl/remove! this))
6364
(.addFirst buf itm)
6465
this)
65-
(close-buf! [this])
66-
clojure.lang.Counted
67-
(count [this]
66+
(close-buf! [_this])
67+
Counted
68+
(count [_this]
6869
(.size buf)))
6970

7071
(defn sliding-buffer [n]
@@ -88,7 +89,7 @@
8889
(close-buf! [_]
8990
(when (undelivered? val)
9091
(set! val nil)))
91-
clojure.lang.Counted
92+
Counted
9293
(count [_]
9394
(if (undelivered? val) 0 1)))
9495

src/main/clojure/clojure/core/async/impl/channels.clj

+28-28
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
(:require [clojure.core.async.impl.protocols :as impl]
1212
[clojure.core.async.impl.dispatch :as dispatch]
1313
[clojure.core.async.impl.mutex :as mutex])
14-
(:import [java.util LinkedList Queue Iterator]
15-
[java.util.concurrent.locks Lock]))
14+
(:import [java.util LinkedList Queue]
15+
[java.util.concurrent.locks Lock]
16+
[clojure.lang IDeref]))
1617

1718
(set! *warn-on-reflection* true)
1819

@@ -22,7 +23,7 @@
2223
(throw (new AssertionError (str "Assert failed: " ~msg "\n" (pr-str '~test))))))
2324

2425
(defn box [val]
25-
(reify clojure.lang.IDeref
26+
(reify IDeref
2627
(deref [_] val)))
2728

2829
(defprotocol MMC
@@ -174,31 +175,30 @@
174175
(.unlock handler)
175176
take-cb))]
176177
(if (and buf (pos? (count buf)))
177-
(do
178-
(if-let [take-cb (commit-handler)]
179-
(let [val (impl/remove! buf)
180-
iter (.iterator puts)
181-
[done? cbs]
182-
(when (and (not (impl/full? buf)) (.hasNext iter))
183-
(loop [cbs []
184-
[^Lock putter val] (.next iter)]
185-
(.lock putter)
186-
(let [cb (and (impl/active? putter) (impl/commit putter))]
187-
(.unlock putter)
188-
(.remove iter)
189-
(let [cbs (if cb (conj cbs cb) cbs)
190-
done? (when cb (reduced? (add! buf val)))]
191-
(if (and (not done?) (not (impl/full? buf)) (.hasNext iter))
192-
(recur cbs (.next iter))
193-
[done? cbs])))))]
194-
(when done?
195-
(abort this))
196-
(.unlock mutex)
197-
(doseq [cb cbs]
198-
(dispatch/run #(cb true)))
199-
(box val))
200-
(do (.unlock mutex)
201-
nil)))
178+
(if-let [take-cb (commit-handler)]
179+
(let [val (impl/remove! buf)
180+
iter (.iterator puts)
181+
[done? cbs]
182+
(when (and (not (impl/full? buf)) (.hasNext iter))
183+
(loop [cbs []
184+
[^Lock putter val] (.next iter)]
185+
(.lock putter)
186+
(let [cb (and (impl/active? putter) (impl/commit putter))]
187+
(.unlock putter)
188+
(.remove iter)
189+
(let [cbs (if cb (conj cbs cb) cbs)
190+
done? (when cb (reduced? (add! buf val)))]
191+
(if (and (not done?) (not (impl/full? buf)) (.hasNext iter))
192+
(recur cbs (.next iter))
193+
[done? cbs])))))]
194+
(when done?
195+
(abort this))
196+
(.unlock mutex)
197+
(doseq [cb cbs]
198+
(dispatch/run #(cb true)))
199+
(box val))
200+
(do (.unlock mutex)
201+
nil))
202202
(let [iter (.iterator puts)
203203
[take-cb put-cb val]
204204
(when (.hasNext iter)

src/main/clojure/clojure/core/async/impl/concurrent.clj

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
(let [counter (atom 0)]
2525
(reify
2626
ThreadFactory
27-
(newThread [this runnable]
27+
(newThread [_this runnable]
2828
(let [body (if init-fn
2929
(fn [] (init-fn) (.run ^Runnable runnable))
3030
runnable)

src/main/clojure/clojure/core/async/impl/exec/threadpool.clj

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
(ns clojure.core.async.impl.exec.threadpool
1010
(:require [clojure.core.async.impl.protocols :as impl]
1111
[clojure.core.async.impl.concurrent :as conc])
12-
(:import [java.util.concurrent Executors Executor]))
12+
(:import [java.util.concurrent Executors]))
1313

1414
(set! *warn-on-reflection* true)
1515

@@ -28,5 +28,5 @@
2828
(conc/counted-thread-factory "async-dispatch-%d" true
2929
{:init-fn init-fn}))]
3030
(reify impl/Executor
31-
(impl/exec [this r]
31+
(impl/exec [_ r]
3232
(.execute executor-svc ^Runnable r))))))

src/main/clojure/clojure/core/async/impl/ioc_alt.clj

-7
This file was deleted.

0 commit comments

Comments
 (0)