Fork me on GitHub

@drewverlee For that specific linter, what I would do is look at analyzer.clj if we already have a special case for loop and recur. Then when going into the analysis for loop, add a key with a volatile or so to the ctx which tells us that we are inside of the loop. Then when encountering recur, you put a boolean true in the volatile (given that the volatile is there). Then after analyzing the body of loop, you will know that there was a recur. If not, emit a warning. Something like that.


About the REPL: don't know what you are doing, but I keep my tooling pretty basic. No magic jack-in so my dependencies are always known and don't upgrade automagically. Just a plain clj REPL + require + :reload also goes a long way I find. Pretty primitive, but this way I can even reload code in a node REPL easily.


Other than that, I very often just invoke clj-kondo from the command line with clojure -M:clj-kondo/dev --lint /tmp/example.clj to test out dev stuff

Drew Verlee16:08:12

Correct me if i'm wrong, But I don't think there is a way to have a clojure project linked to a cider version. As locking down the deps on nrepl, only shift the issue to the emacs cider client. That is why i prefer to not declare a cider version, so that I don't get the emacs client and the cider repl out of sync. E.g if i use your cider deps version i get warnings right away: WARNING: CIDER 1.2.0-snapshot requires cider-nrepl 0.26.0, but you're currently using cider-nrepl 0.22.0-beta4. The version mismatch might break some functionality! (More information) WARNING: clj-refactor and refactor-nrepl are out of sync. Their versions are 2.5.1 (package: <tel:202106281154|20210628.1154>) and 2.5.0-SNAPSHOT, respectively. You can mute this warning by changing cljr-suppress-middleware-warnings. Which means i would have to change the version on my cider emacs client. I'll find a way to work around it, I just wanted to be sure we (I) understood the trade off. As an aside, maybe there should be a way to auto install the matching version on the client?


you can include aliases from your ~/.clojure/deps.edn

Drew Verlee16:08:04

I understand, i did that. Then cider client on emacs complains about the versions you as per the error above. I suppressed the warnings and was able to use debug and some other features, hopefully thats good enough. I don't want to distract from the more important issue. 🙂


You can develop how you like, I just shared how I did it and that may or may not work for you :)

👍 2

making my first clj-kondo config 🙂 I am wondering how to resolve some of my macros so the bindings are recognized. They all look similar to this:

(with-something [a bindings & body])
(with-something-else [a b c bindings & body])
I think the idea should be to have the bindings argument in particular be recognized.. I tried something like this
:hooks {:analyze-call {my.ns/with-something ,,,
but either this does not work or my config is not reloaded (not sure how to trigger that besides restarting spacemacs)


@nha to test config I think it's best to invoke clj-kondo from the command line and stick some println in the hook function


right, I was hoping there would be something like with-open but where I can tell clj-kondo where is the bindings vector. Will try from the cli


@nha you might also be able to copy your macros as is into same named namespaces into the config dir


and then use the new :macroexpand option


I think that’s what I am doing. Getting a warning from the cli straight away though

....WARNING: file macroexpand/one_of.clj not found while loading hook


did you maybe use a hyphen in the filename instead of underscore? and are these files inside your .clj-kondo dir?


> macroexpand/one_of.clj is an example from clj-kondo's own codebase btw


aah it’s not built-into kondo then? that would be my error


this config: my.ns/with-something needs to look like my.ns/with-something your-code/your-macro


right, I get it now. I assumed it was built-in. My mistake 🙂

Drew Verlee21:08:23

@borkdude I had some time to look into a solution for the loop-missing-recur issue as previously discussed. its chilling before i open the PR though i want to do some more work. I was looking at the contribute guidelines at the diff tool and it seems to print out a lot of stuff. Is that still relevant? e.g ./script/diff Maybe its doing what it intended, at a glance it seemed to have more then i though i changed.

Drew Verlee21:08:04

also, is this the right place to ask these questions 🙂


@drewverlee yeah that's still relevant. it should not output any new warnings

Drew Verlee21:08:14

kk. ill double check.


@drewverlee I think your code looks good, except for one thing, I hinted at above. I don't like to walk ASTs multiple times and do everything as much as possible in one pass.


you can do it in the way I hinted there, or there's another way, to inspect all calls to recur and then look up the :callstack, that would perhaps work, I'm not completely sure


also one challenge is to verify if the recur you are looking at belongs to the specific loop you're analyzing


it could also be an inner anonymous function for example


I'll be back tomorrow for more questions. Nice work so far

Drew Verlee22:08:58

Thanks, good observations. I'll have to tackle them tomorrow to.