Fork me on GitHub
Marc O'Morain09:05:36

btw, when I upgraded to the latest release, the number warnings in our main codebase went from 73 to 340 😄

Marc O'Morain09:05:53

I believe they are all legit


whoops 🙂 if there any false positives, please notify me


there were some false positives regarding unused namespaces which @mynomoto reported, these are now fixed on master

Marc O'Morain09:05:46

> clj-kondo --lint . | tail -1
linting took 12508ms, errors: 11, warnings: 122
> clj-kondo --lint "$(lein classpath)" | tail -1
linting took 45004ms, errors: 268, warnings: 487
> lein clj-kondo --lint . | tail -1
linting took 9267ms, errors: 0, warnings: 0
> lein clj-kondo --lint "$(lein classpath)" | tail -1
linting took 23855ms, errors: 0, warnings: 306
One of my colleagues has noticed some non-determinism yesterday.

Marc O'Morain09:05:12

I’ve not looked in this yet.


yeah, the lein version can be faster because of JIT I guess


so for big workloads the JVM might be the preferred mode

Marc O'Morain09:05:06

The issue is that the number of warnings changed


@marc-omorain that shouldn’t be the case, so it’s either a bug or you’re not using the same version. can you check by doing clj-kondo --version vs lein clj-kondo --version?

Marc O'Morain09:05:53

oh that’s it! I didn’t see that one invocation was from lein and one wasnt

Marc O'Morain09:05:15

We’ve found one fun false positive. We have a test that calls (is (thrown+ ...)), and that namespace requires slingshot.test, which is marked as unused. is calls a multimethod assert-expr which is defined for the thrown? and thrown-with-msg? symbols by clojure.test. slingshot.test adds methods for thrown+? and thrown+-with-msg?. By requiring slingshot.test we are extending the multimethod.



Borkdude@michiel ~ $ cat /tmp/foo.clj
(ns foo
  (:require [slingshot.test]))

Borkdude@michiel ~ $ clj-kondo --lint /tmp/foo.clj
/tmp/foo.clj:2:14: warning: namespace slingshot.test is required but never used
linting took 12ms, errors: 0, warnings: 1
Borkdude@michiel ~ $ clj-kondo --lint /tmp/foo.clj --config --config '{:linters {:unused-namespace {:exclude [slingshot.test]}}}'
linting took 11ms, errors: 0, warnings: 0


Maybe I should change the name :unused-namespace to something else?

Marc O'Morain10:05:43

MY colleague has just committed that 😄

Marc O'Morain10:05:11

(deftest two-cases
  (let [resource (load-some-resource)]
    (let [result (do-something resource)]
      (is (= 2 (count result))))
    (let [result (do-something-else resource)]
      (is (= 3 (count result))))))
We have some tests like this that complains about a redundant let ^


usually a redundant let is really redundant, but in this case probably not. you could write:

(deftest two-cases
  (let [resource (load-some-resource)
        result (do-something resource)
        _ (is (= 2 (count result)))
        result (do-something-else resource)]
    (is (= 3 (count result)))))
not sure how clj-kondo should be configured to be silent about this case. I’ll think about it. maybe the redundant let can be more intelligent


maybe redundant let should only complain if there is one single child in a let that is a let, that seems reasonable

Marc O'Morain10:05:36

We are about to remove a load of test harness with clj-kondo

Marc O'Morain10:05:11

We have a script that asserts that every namespace in src is required from a file in test.

Marc O'Morain10:05:00

This was put in place when someone committed a file in src that didn’t compile, it never had a test, and it broken in prod

Marc O'Morain10:05:26

We can now just lein clj-kondo --lint ${lein classpath}