clj-kondo

https://github.com/clj-kondo/clj-kondo
gordon 2020-04-29T10:53:48.044800Z

We're using (and loving) clj-kondo, but I was wondering if anybody has found a nice, automated, way for clj-kondo to play well with HugSQL? HugSQL defines functions at namespace load-time, and tickles the undeclared-var linter. We can declare the vars before invoking HugSQL, or we can configure clj-kondo to ignore those particular vars, but neither solution is particularly elegant, they both need manual updating if we add more HugSQL functions.

borkdude 2020-04-29T10:55:40.046500Z

@gordonsyme_clojurians I use hugsql and I do use declare. Another way is to just turn the unresolved symbol linter off for that namespace. Another workaround: use a small namespace foo.db.hugsql in which you let hugsql create the functions. then you require that namespace from foo.db as [foo.db.hugsql :as queries] and voila, no more warnings. you just type queries/select-users and clj-kondo won't complain anymore

borkdude 2020-04-29T10:56:26.047200Z

I just thought about that last way while typing, I think I'm going to try that myself as well

gordon 2020-04-29T10:58:36.047800Z

Thanks, that's a neat idea!

mafcocinco 2020-04-29T12:27:33.049500Z

We also use HugSQL. That is a neat idea! We currently use the declare approach (which was originally suggested to me by @borkdude). It works great and, though it requires some discipline to keep in sync with the corresponding file, does have the nice side benefit of providing a .clj file where a person could look to see what functions are available without having to look through the SQL.

mafcocinco 2020-04-29T12:30:51.053100Z

Our namespacing is similar, which makes it very easy to navigate the code. Generally, our (Hug) .sql files are kept on a path project/sql/schema_name/table_name.sql and are then loaded by a .clj file located at project.queries.schema_name.table_name. Any namespace that needs to interact with the specified table includes the project.queries.* namespace and has all the functions they need. Has made it pretty simple (i.e. predictable) for devs to navigate the various HugSQL functions within a project.

plins 2020-04-29T19:27:13.054400Z

hello, Im trying to work with slingshot/try+ and Id like to know If there is a macro in clojure like

(catch [:type error/not-found] {:keys [msg]}
  ...)
so I can use lint-as

borkdude 2020-04-29T19:30:23.055Z

I don't think there is. Probably the :unresolved-symbol config is what you need here

plins 2020-04-29T20:10:37.055800Z

did this, the warning went away, but what happens then? everything inside the try+ block is ignored?

borkdude 2020-04-29T20:35:11.056800Z

the false positives because of that macro are gone, at the cost of false negatives

borkdude 2020-04-29T20:36:04.057500Z

slingshot/try+ seems like a library that is used quite a lot, so I'd be happy to get built-in support for that. feel free to post an issue about it

borkdude 2020-04-29T20:36:21.057700Z

I don't personally use it

plins 2020-04-29T21:42:02.057900Z

ok thanks Ill do that 🙂

plins 2020-04-29T21:46:38.058200Z

https://github.com/borkdude/clj-kondo/issues/874 hope its descriptive enough

borkdude 2020-04-29T21:47:00.058500Z

yes, thank you

🎉 2