clj-kondo

borkdude 2025-06-28T19:09:26.411969Z

I added a new linter on master: :locking-suspicious-lock which warns on locking usage that looks... suspicious. Thanks @nbtheduke for the idea. The linter warns on three issues: locking with a single argument which probably means you forgot to provide a body or a lock. Locking on interned values like keywords, strings. And locking on a non-symbol expression which likely means you created the lock locally of the locking expression. Please check your projects if you can find any regressions or false positives regarding locking:

clj -Sdeps '{:deps {clj-kondo/clj-kondo {:git/url "" :git/sha "1c2c986d888a0f8352e4cd0294f87887d0192fc1"}}}' -M -m clj-kondo.main --lint src

borkdude 2025-06-29T09:22:49.191599Z

I've never seen that happen in real code, but perhaps that could be generalized to something like catch without try

borkdude 2025-06-29T09:23:31.830539Z

I mean, you can come up with all kinds of stuff that messes up Clojure, but a linter imo is supposed to catch stuff which you tend to do accidentally

Alex Miller (Clojure team) 2025-06-28T20:00:09.065239Z

Some numeric boxed values are also interned, just probably weird to lock on them regardless

✅ 1
borkdude 2025-06-28T20:13:16.897739Z

Yeah numbers I’ll add them

2025-06-29T06:18:32.207119Z

Here's some more ideas for suspicious locking expressions: https://github.com/frenchy64/fully-satisfies/blob/265aa2466a529dea96cecbdcaf17368c8315ebf0/test/io/github/frenchy64/fully_satisfies/non_leaky_macros_test.clj#L13-L31

(fn [Exception e catch] (locking :irrelevant (catch Exception e)))
Looks like the body is a function call of 2 args to catch, but always returns nil since it expands into
(try (catch Exception e))