clj-kondo

https://github.com/clj-kondo/clj-kondo
FiVo 2020-08-14T08:57:36.010700Z

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?

yuhan 2020-08-14T10:23:52.010800Z

It's undefined behaviour: https://github.com/borkdude/clj-kondo/issues/782

seancorfield 2020-08-14T17:09:55.012200Z

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

seancorfield 2020-08-14T17:13:48.014400Z

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

seancorfield 2020-08-14T17:17:15.015Z

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

seancorfield 2020-08-14T17:17:35.015400Z

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

borkdude 2020-08-14T17:28:13.017Z

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

borkdude 2020-08-14T17:29:01.017700Z

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 had

borkdude 2020-08-14T17:30:58.017900Z

Thanks for answering this.

seancorfield 2020-08-14T17:56:26.018900Z

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

seancorfield 2020-08-14T17:57:29.019700Z

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.

seancorfield 2020-08-14T17:58:02.020100Z

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

borkdude 2020-08-14T17:58:13.020500Z

Hope you are enjoying the new one

seancorfield 2020-08-14T17:58:42.021100Z

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

👍 1
borkdude 2020-08-14T18:02:19.022400Z

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

borkdude 2020-08-14T18:02:30.022600Z

And a whole bunch of tiny fixes.

borkdude 2020-08-14T18:02:55.022900Z

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

seancorfield 2020-08-14T18:07:28.023600Z

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

borkdude 2020-08-14T18:07:55.023900Z

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

borkdude 2020-08-14T18:08:19.024100Z

Here's some examples: https://github.com/borkdude/clj-kondo/tree/master/examples/