Fork me on GitHub
#clj-kondo
<
2021-05-26
>
d5p04:05:27

hi, is it possible to somehow exclude unused namespace/unused referred var warnings just for a certain namespace , we use mount and have a core ns that refers to a few to ensure they load , so would like to exclude these warnings just in that ns

seancorfield04:05:18

@d5p How exactly are you requiring those namespaces? What exact syntax are you using?

seancorfield04:05:27

I think that if you (:require [some.namespace]) like that rather than (:require some.namespace) that clj-kondo won't warn about it being otherwise unused?

d5p04:05:40

i’m requiring them like

d5p04:05:43

(ns taskmanager.core
  (:require [taskmanager.batch.alerts :refer [task-alert-consumer]]
            [taskmanager.batch.batch :refer [batch-task-consumer incoming-batch-task-consumer]]
            [taskmanager.config :refer [project config]]
            [taskmanager.http :refer [http-server]]
            [taskmanager.db :refer [*db*]]
            [taskmanager.redis-client :refer [*redis-client*]]
            [taskmanager.queue :refer [sqs-buffered-client]])
  (:gen-class))

d5p04:05:59

and it reports all of them as unused

seancorfield04:05:17

Because you're not using any of the referred symbols?

d5p04:05:27

yeh, they’re just required in this ns to ensure mount can start them

seancorfield04:05:36

Take the :refer's out.

seancorfield04:05:50

if you're not using the symbols that is why you're getting warnings.

d5p04:05:29

ha , was hoping it would be something dumb and easy, and can’t get easier than that! been explicitly referring the states for years and never really thought about it, thanks!

3
👍 3
Adam Helins17:05:39

In hooks, what is the rationale for dealing with the clj-rewrite structures instead of taking and returning raw Clojure forms? Is is just for performance? Not complaining or anything, just thinking about linting Convex Lisp (very similar to Clojure) and wondering about what you really gain by keeping that kind of AST.

borkdude17:05:27

@adam678 The reason is preservation of information mostly

borkdude17:05:13

when I wrote the hooks stuff, I did try to make it look like normal macroexpansion, but this didn't work out as you would lose too much location information, e.g. when you transform a body that contains numbers, strings, etc

borkdude17:05:33

so I decided to expose the structure that clj-kondo itself uses

borkdude17:05:45

and by now rewrite-clj is a pretty solid library in the clj ecosystem

Adam Helins17:05:56

Now that you mention it, it's true there is quite a lot you could loose by using sexprs only, depending on use case 👍