This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # aleph (4)
- # announcements (5)
- # architecture (1)
- # aws (5)
- # babashka (12)
- # beginners (143)
- # chlorine-clover (4)
- # cider (16)
- # clj-kondo (44)
- # cljfx (26)
- # cljsrn (2)
- # clojure (34)
- # clojure-europe (28)
- # clojure-gamedev (1)
- # clojure-nl (3)
- # clojure-provo (2)
- # clojure-spec (6)
- # clojure-uk (17)
- # clojurescript (99)
- # code-reviews (6)
- # core-async (15)
- # cryogen (9)
- # cursive (14)
- # data-science (1)
- # datomic (16)
- # duct (1)
- # events (4)
- # exercism (1)
- # figwheel-main (3)
- # fulcro (3)
- # hugsql (7)
- # leiningen (4)
- # malli (15)
- # off-topic (13)
- # pathom (8)
- # re-frame (7)
- # reitit (35)
- # remote-jobs (1)
- # sci (10)
- # shadow-cljs (32)
- # sql (5)
- # tools-deps (102)
- # tree-sitter (3)
- # uncomplicate (7)
- # vim (40)
- # xtdb (8)
Hi everyone, just started using kondo. question. what should I do to make it not complain about my macros? Or better, to make it check macros correctly?
@jimka.issy There are several options for this: https://github.com/borkdude/clj-kondo/blob/master/doc/config.md#unrecognized-macros
hmmm. are those workarounds really satisfying to kondo users?
I use lots of macros in my code, it would be great if kondo would check the expanded code.
and even report that macroexpand fails.
@jimka.issy This is a general problem in Clojure and static analysis tooling. The trade off is either execute macros at the penalty of performance and launching missiles or mechanisms like this to assist static analysis which make it feasible for near realtime feedback
The closest thing for making clj-kondo aware of your custom macros and getting good custom checks is writing hooks for it. The other options are linting as existing macros or suppressing warnings.
yes, that is a real trade off. I realize that some macros (even some of my own) are really cpu intensive. But I'd love the option, as most macros are NOT cpu intensive, but simple code transformations.
When writing the hooks API I have considered that. But it isn't possible since keywords, numbers, strings etc, do not carry metadata, so you will lose location information. It's not likely that clj-kondo will support executing user macros as is anytime soon.
is clj-kondo executing in a different process? or is it executing in the same nrepl process as emacs/cider is using?
Clj-kondo is its own environment, not attached to the JVM at all (if you're running the binary)
it's not using the JVM? that sounds like a huge amount of work.
You can lint arbitrary .clj and .cljs files on a system without any other Clojure tools on it
@jimka.issy If you like to use a JVM-attached linter that will expand your macros take a look at eastwood
do my comments echo every first-time user's comments? sorry if they do.
It's a common question, but in most projects I've worked on, the macro config only contains a hand full of things
In Clojure writing lots of macros isn't really encouraged anyway. Clj-kondo supports most well known macros, at least from Clojure itself and several popular libraries
It seems I looked at eastwood sometime ago and abandoned it. Perhaps because it easily gets confused with namespaces.
Here is a repo with hooks for some libraries: https://github.com/clj-kondo/config
not your fault of course, but it is unfortunate that such a powerful feature of the language is discouraged.
Ever heard of the first rule of macro club? :) https://stuartsierra.com/download/2010-10-23-clojure-conj-macro-club.pdf
I mean, I do use them, and it's annoying that clj-kondo doesn't recognize the syntax out of the box, but it's not something I can easily fix while also keeping clj-kondo fast and accurate
kondo does find lots of problems with my code. notably misplaced docstrings.
I very often use the Common Lisp definition order.
@jimka.issy The initial inspiration for clj-kondo was joker: it's a linter that I could easily hook up with emacs and it worked without a running REPL. I extended the way it works with more features and this became clj-kondo. You can watch the talk in the README (ca. 20 minutes long) if you want to know more about how clj-kondo works and the trade-offs it makes.
how does condo figure out whether a symbol is resolvable. It seems to get this wrong in lots of cases for me.
I suspect it is related to
(in-ns ...) does clj-kondo know that top-level regions between two calls to
(in-ns ...) should be interpreted in the name space specified?
It knows. But if clj-kondo hasn't linted the other ns yet, it might not know which symbols are in it. To make clj-kondo aware of this, you should do this: https://github.com/borkdude/clj-kondo/#project-setup
yes I did that before I started. do I need to redo it from time to time?
in that case, it might be a bug. Not sure. If you can make a repro as in: I've linted this file and I'm using in-ns of the ns of that file in this other file, but it doesn't work, I will take a look.
BTW when I parallel lint, it printed out volumes of diagnostics from libraries I'm referencing
I'm happy to send you the issue by email, or chat, or and also happy to file it in the issue tracker on github as you prefer.
By "Which platform are you using?" You mean Mac/Linux/windows?
OK, I filed a issue #1054 https://github.com/borkdude/clj-kondo/issues/1054 Thanks for the offer to take a look.
Thanks. I hope to take a look soon. I think the in-ns logic might not remember the requires from the original ns well enough, something along those lines.
meanwhile, as a workaround you can use namespace local config to suppress those symbols
Users of clj-kondo may also like: https://github.com/borkdude/grasp I just added an example of how to find all occurrences of keywords in e.g. a re-frame app: https://github.com/borkdude/grasp#finding-keywords Discuss in #grasp for more.