Fork me on GitHub
#clj-kondo
<
2021-04-01
>
michal07:04:17

hey, I believe it was asked hundreds times here, but I'm still unable to find a solution - unresolved vars when linting a code with hugsql generated functions. in general all the calls like db/find-user-by-id are ignored (as the documentation says) but only as long as I do not re-evaluate the db namespace again (which auto re-generates functions). then, to get rid of clj-kondo warnings I need to clear the .clj-kondo/.cache and the linter is happy again. well... till next evalutation, which happens quite often as that's the way of refreshing hugsql functions after changes made in SQL queries.

michal07:04:51

is there anyway of making clj-kondo aware of the namespace evaluation and force it to clean its cache?

borkdude08:04:08

@michal you can ignore the vars in db by adding it to {:linters {:unresolved-var {:exclude [db]}}}

michal09:04:16

awesome, namespace exclusion does its job. thanks!

borkdude08:04:39

I think you should not see unresolved vars in a hugsql namespace if there are no other user defined functions in the source though

borkdude08:04:06

the way I am using hugsql is to make special foo.db.hugsql namespaces where only the vars from hugsql are defined and I call those from foo.db

delaguardo13:04:28

warning: Unresolved var: async/<!! I start getting this warning recently, probably because in clojure.core.async <!! is not a defn or macro anymore. it is defblockingop now - https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L125-L136

borkdude14:04:08

Feel free to post an issue. For now you can fix this in your config with :lint-as

delaguardo13:04:55

this one is tricky because you might want to have deliberately two different implementations for the same dispatch value. For instance - in two separate namespaces

souenzzo13:04:37

it isn't a anti-pattern? can be an "disabled by default" lint?

delaguardo13:04:49

sure it can be disabled by default

delaguardo13:04:06

I found it useful in combination with integrant and “multi-artifact project” (one source distributed as a multiple slightly differently configured jars)

borkdude14:04:34

already logged, feel free to give feedback there: https://github.com/clj-kondo/clj-kondo/issues/1061

pinkfrog14:04:33

Can clj-kondo update source file?

borkdude14:04:35

Clj-kondo does not update your code. You might want to look at clojure-lsp for this.

borkdude14:04:46

It uses clj-kondo and then actions on its findings.

pinkfrog14:04:05

clojure-lsp? seems a similar product of cider

borkdude14:04:34

it can do more than cider though in terms of rewriting your code. what kind of stuff would you like to "update"?

pinkfrog15:04:43

some unused imports

vemv20:04:43

refactor-nrepl can do this. That specific functionality doesn't actually use much nrepl or tools.analyzer stuff iirc - I think it's more lightweight. I've been thinking of creating a "spin-off" of refactor-nrepl just for that - otherwise it's bit of a delicate dependency to ask people to have