Hey, I am wondering if the unresolved symbol in the destructuring of the following example is intended ?
(defn foo [x {:keys [y] :or {y x}}]
(list x y))
Is that considered bad style or a bug?It's undefined behaviour: https://github.com/borkdude/clj-kondo/issues/782
(ns foobar
{:clj-kondo/config {}}
(:require [<http://clojure.java.io|clojure.java.io> :as io]))
^ Does not flag io
as an unused namespace. Remove the :clj-kondo/config
metadata and it works:
(ns foobar
#_{:clj-kondo/config {}}
(:require [<http://clojure.java.io|clojure.java.io> :as io]))
I don't see an existing issue for this, shall I go ahead and create one @borkdude?
Never mind. I updated to the most recent clj-kondo
version and the problem went away!
(FYI, the above bug was in the 2020.04.05 version)
@seancorfield Could be an issue with parsing the clj-kondo config. Before it expected quotes like
{:clj-kondo/config '{}}
but this has been relaxed to
{:clj-kondo/config {}}
if your config doesn't contain any symbols.Note that
(ns foobar
{:clj-kondo/config 1}
(:require [<http://clojure.java.io|clojure.java.io> :as io]))
won't give you an error about io being unused either, since the parsing of the config fails, so maybe it's similar to what you hadThanks for answering this.
@borkdude I had '
in the real code example. What I posted was just the minimal example of the bug (which has clearly since been fixed).
It was definitely parsing the config correctly: it contained a :lint-as
and without the form, Kondo flagged every use of that macro as an error.
I didn't realize I was on such an old version of Kondo.
Hope you are enjoying the new one
(I'm refactoring old test code right now so Kondo is helping me cleanup ns
forms as I swap out uses of an old lib for uses of a new one!)
@seancorfield I think the most exciting new features since 2020.04.05 are hook support (for handling weird macros that don't work with :lint-as
) and linting for clojure.core/format
.
And a whole bunch of tiny fixes.
The thing you did for jdbc can now be done in user-land using hooks. The hooks are evaluated using sci (because a GraalVM binary cannot clojure.core/eval
).
Yeah, I haven't had time to look at hooks yet, but they look very interesting.
At the moment it's probably mostly used by Rum users
Here's some examples: https://github.com/borkdude/clj-kondo/tree/master/examples/