Fork me on GitHub
#clj-kondo
<
2023-05-04
>
Alexander Kouznetsov01:05:33

How can I suppress unused-public-var for a macro that creates tests with some parameters (i. e. defmytest name [bindings])? Currently I’m using lint-as with def-catch-all or defn but that creates this unused public var warning.

ericdallo13:05:08

if you lint-as deftest should work

Alexander Kouznetsov01:05:52

Can clj-kondo catch with-redefs mismatch of the number of params comparing to the original function?

borkdude15:05:13

I'm not sure what you mean by this. Could you give an example?

Alexander Kouznetsov17:05:04

Let’s say I have a function a that takes 4 parameters. I then make a refactor so now it takes 5 parameters. At the same time I have a test where it is redefined as (with-redefs [a (fn [_ _ _ _] mock-value)] …) , can clj-kondo warn that here it needs to be updated to take 5 params?

borkdude17:05:26

can you provide a full example? a .clj file that I can lint locally?

Alexander Kouznetsov22:06:43

Will something as simple as this work?

(defn x [a b] (+ a b))

(defn y [] (x 10 20))

(with-redefs [x (fn [a] a)] (y))

borkdude09:06:41

This currently isn't supported yet, but could be nice enhancement, please post an issue if you wish

gratitude-thank-you 2
Thiago Carvalho Pinto13:05:00

I would like to suggest clj-kondo to support regex in the analyze-call, something like

{:hooks {:analyze-call {"my-project/.*/some-fn" some-dep/some-fn}}}
I have a case at work where we have a lot of namespaces that have to be included in the analyze-call list, and also a new use case that we have the project name in the namespace, so it is get harder to make this list generic without having something like a regex. What do you think?

borkdude13:05:36

There is a concept in the config called :ns-groups . You can make an ns group based on a regex pattern and then use that group name in the config. We could extend that to here too

nice 1
borkdude14:05:14

issue welcome

Thiago Carvalho Pinto17:05:48

Cool! This solution sounds good!

Thiago Carvalho Pinto17:05:06

I'll open an issue.. thank you!

xbrln18:05:16

How can one ask clj-kondo to give a warning about an unused global declaration ? I have a function which is not used anywhere, and I would like clj-kondo to give me a warning about it. I run clj-kondo as git commit hook like clj-kondo --lint src, it uses a config file from .clj-kondo/config.edn. Ideally I want to add a keyword in that config under :linters which does that.

borkdude18:05:24

either use: • https://github.com/borkdude/carve • clojure-lsp unused-vars both are based on clj-kondo

xbrln19:05:56

Am using leiningen, so will try carve with babashka. Thank you 🙏

borkdude19:05:35

you should be able to run it with lein as well: similar to this: https://github.com/clj-kondo/clj-kondo/blob/master/doc/jvm.md#leiningen