This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-16
Channels
- # announcements (5)
- # aws (34)
- # beginners (145)
- # cider (48)
- # circleci (8)
- # clara (7)
- # clj-kondo (28)
- # cljs-dev (75)
- # cljsrn (4)
- # clojure (325)
- # clojure-czech (10)
- # clojure-europe (5)
- # clojure-italy (4)
- # clojure-nl (4)
- # clojure-spec (6)
- # clojure-sweden (3)
- # clojure-uk (70)
- # clojurescript (18)
- # clr (1)
- # community-development (2)
- # cursive (38)
- # data-science (7)
- # datascript (14)
- # datomic (22)
- # emacs (2)
- # figwheel (1)
- # fulcro (6)
- # graalvm (22)
- # graphql (11)
- # hoplon (12)
- # jackdaw (8)
- # jobs-discuss (16)
- # juxt (5)
- # leiningen (19)
- # luminus (5)
- # nrepl (2)
- # nyc (1)
- # off-topic (6)
- # overtone (2)
- # pedestal (10)
- # re-frame (6)
- # reagent (8)
- # reitit (1)
- # rewrite-clj (43)
- # ring (2)
- # shadow-cljs (124)
- # testing (1)
- # vim (22)
- # xtdb (77)
- # yada (4)
@marc-omorain https://www.dropbox.com/s/r96ntgce3kps3w3/Screenshot%202019-05-16%2011.06.27.png?dl=0
btw, when I upgraded to the latest release, the number warnings in our main codebase went from 73 to 340 😄
I believe they are all legit
there were some false positives regarding unused namespaces which @mynomoto reported, these are now fixed on master
> 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.I’ve not looked in this yet.
The issue is that the number of warnings changed
I’m still not entirely happy about this message: https://www.dropbox.com/s/7pmy4t8x7hzzgl7/Screenshot%202019-05-16%2011.08.52.png?dl=0
@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
?
oh that’s it! I didn’t see that one invocation was from lein
and one wasnt
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
MY colleague has just committed that 😄
(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 intelligentmaybe redundant let should only complain if there is one single child in a let that is a let, that seems reasonable
We are about to remove a load of test harness with clj-kondo
We have a script that asserts that every namespace in src
is required from a file in test
.
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
We can now just lein clj-kondo --lint ${lein classpath}