This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-09
Channels
- # announcements (5)
- # aws (5)
- # babashka (7)
- # beginners (152)
- # cider (10)
- # clj-kondo (30)
- # clj-on-windows (1)
- # cljs-dev (14)
- # cljsrn (19)
- # clojure (94)
- # clojure-australia (4)
- # clojure-europe (43)
- # clojure-nl (2)
- # clojure-uk (11)
- # clojurescript (16)
- # clojureverse-ops (5)
- # code-reviews (7)
- # community-development (6)
- # core-async (29)
- # cursive (50)
- # datomic (22)
- # docker (10)
- # figwheel-main (3)
- # fulcro (4)
- # graalvm (1)
- # introduce-yourself (2)
- # kaocha (9)
- # lambdaisland (2)
- # lsp (19)
- # malli (37)
- # off-topic (50)
- # polylith (8)
- # portal (1)
- # reagent (10)
- # rum (1)
- # shadow-cljs (24)
- # spacemacs (14)
- # yada (2)
@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
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?
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 :)
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 macroexpand.one-of/one-of ,,,
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
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?
ooh gotcha https://github.com/clj-kondo/clj-kondo/blob/master/.clj-kondo/macroexpand/one_of.clj
this config: my.ns/with-something macroexpand.one-of/one-of
needs to look like my.ns/with-something your-code/your-macro
@borkdude I had some time to look into a solution for the loop-missing-recur issue as previously discussed. its chilling https://github.com/clj-kondo/clj-kondo/compare/master...drewverlee:issue-426-warning-for-a-loop-without-a-recur?expand=1 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.
also, is this the right place to ask these questions 🙂
@drewverlee yeah that's still relevant. it should not output any new warnings
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
Thanks, good observations. I'll have to tackle them tomorrow to.