Fork me on GitHub
#clj-kondo
<
2020-08-14
>
finn.volkel08:08:36

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?

borkdude17:08:58

Thanks for answering this.

seancorfield17:08:55

(ns foobar
  {:clj-kondo/config {}}
  (:require [ :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 [ :as io]))

seancorfield17:08:48

I don't see an existing issue for this, shall I go ahead and create one @borkdude?

seancorfield17:08:15

Never mind. I updated to the most recent clj-kondo version and the problem went away!

seancorfield17:08:35

(FYI, the above bug was in the 2020.04.05 version)

borkdude17:08:13

@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.

borkdude17:08:01

Note that

(ns foobar
  {:clj-kondo/config 1}
  (:require [ :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 had

seancorfield17:08:26

@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).

seancorfield17:08:29

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.

seancorfield17:08:02

I didn't realize I was on such an old version of Kondo.

borkdude17:08:13

Hope you are enjoying the new one

seancorfield17:08:42

(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!)

borkdude18:08:19

@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.

borkdude18:08:30

And a whole bunch of tiny fixes.

borkdude18:08:55

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).

seancorfield18:08:28

Yeah, I haven't had time to look at hooks yet, but they look very interesting.

borkdude18:08:55

At the moment it's probably mostly used by Rum users