Fork me on GitHub

I just noticed that it’s possible to show lint warnings inline on github PRs, seen for elixir below. Looks like it’s done by these Does a similar thing exist for clj-kondo or should we build it?


do you use it on your projects?


I'm using it on clj-kondo :)


Would it make sense or be possible to have kondo warn on use of for in such a way that the comprehension isn’t actually used? I’m working on a legacy code base and I just fixed an evaluation bug caused effectively by

(defn do-lots-of-things
  (when (a-thing?)
    (for [x xs] (do-more-things x)))
  (when (b-thing?)
That is, because the resulting lazy sequence from that for comprehension isn’t used/returned, it didn’t get evaluated.


@U04V15CAJ Pinging about this, had a second thought on this today and I think this would fall under the general category of “unused return values”, which probably can be quite a huge category of things on its own, plus I can imagine the implementation would probably get kinda complex as this would require flow analysis. What I’m trying to say, feel free to say “could be nice but nah” 🙂


There's already an issue for "unused return value" and something I've already worked on a bit


but it's not yet "there"


but returning a lazy sequence isn't wrong, you can't really say that it's unused


Not on its own, of course, in this case the issue is that it’s not in tail position so it gets discarded.


And of course that shouldn’t be a generic check either, as sometimes that’s totally fine, especially with eg. do .


Everything’s difficult, anything’s great 🙂


ah yes, not in tail position, that's a good one

👍 1

We already to tail position analysis for recur


so I guess it would be possible


Sounds potentially great 🙂


It would be this issue: Feel free to post there

👍 1

I was referred here by someone in the general Clojure channel, and I figured Borkdude would know, if anyone did. Is there a library/program for calculating statistics on clojure/script files? I'm thinking about stats like LoC with/without comments, number of functions/macros, depth of expression trees in functions, etc. I looked at clindex, but it didn't seem to give me what I needed.


@fadrian well, the amount of fns vs macros, etc you can get from the clj-kondo analysis: lines of code vs comments, etc you can easily do without any other tools (if you mean ;; comments) expression depths you could do using a tool like tools.reader or edamame which gives you the raw s-expressions and fiddle a bit with that


clojure-lsp also has something like call-tree so it is possible to calculate such trees from clj-kondo's analysis as well


a tool like grasp can help you find certain patterns in clojure code, if that's interesting:


This tool uses clj-kondo's analysis extensively to show dependencies between vars:


Thanks. I figured you'd have your finger on the pulse. I was trying to avoid writing more stuff, and grasp looks like a great starting point.