clj-kondo

https://github.com/clj-kondo/clj-kondo
2021-05-26T04:06:27.059600Z

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

seancorfield 2021-05-26T04:28:18.060200Z

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

seancorfield 2021-05-26T04:30:27.061300Z

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?

2021-05-26T04:30:40.061500Z

i’m requiring them like

2021-05-26T04:30:43.061900Z

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

2021-05-26T04:30:59.062300Z

and it reports all of them as unused

seancorfield 2021-05-26T04:31:17.062700Z

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

2021-05-26T04:31:27.063Z

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

seancorfield 2021-05-26T04:31:36.063200Z

Take the :refer's out.

seancorfield 2021-05-26T04:31:50.063600Z

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

2021-05-26T04:35:29.064500Z

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!

👍 1
1
Helins 2021-05-26T17:01:39.066700Z

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.

borkdude 2021-05-26T17:15:27.067100Z

@adam678 The reason is preservation of information mostly

borkdude 2021-05-26T17:16:13.068Z

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

borkdude 2021-05-26T17:16:33.068500Z

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

borkdude 2021-05-26T17:16:45.069Z

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

Helins 2021-05-26T17:24:56.069800Z

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