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 I've never seen that happen in real code, but perhaps that could be generalized to something like catch without try
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
Some numeric boxed values are also interned, just probably weird to lock on them regardless
Yeah numbers I’ll add them
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))