Fork me on GitHub
#clj-kondo
<
2022-04-05
>
mkvlr07:04:29

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 https://github.com/erlef/setup-beam/blob/main/.github/elixir-matchers.json. Does a similar thing exist for clj-kondo or should we build it?

mkvlr08:04:40

do you use it on your projects?

borkdude08:04:46

I'm using it on clj-kondo :)

eskos07:04:02

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
  [xs]
  (when (a-thing?)
    (for [x xs] (do-more-things x)))
  (when (b-thing?)
    (do-more-stuff)))
That is, because the resulting lazy sequence from that for comprehension isn’t used/returned, it didn’t get evaluated.

eskos10:04:17

@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” 🙂

borkdude10:04:41

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

borkdude10:04:51

but it's not yet "there"

borkdude10:04:27

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

eskos11:04:13

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

eskos11:04:26

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

eskos11:04:03

Everything’s difficult, anything’s great 🙂

borkdude11:04:53

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

👍 1
borkdude11:04:01

We already to tail position analysis for recur

borkdude11:04:05

so I guess it would be possible

eskos11:04:38

Sounds potentially great 🙂

borkdude12:04:14

It would be this issue: https://github.com/clj-kondo/clj-kondo/issues/1258 Feel free to post there

👍 1
fadrian20:04:00

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.

borkdude20:04:50

@fadrian well, the amount of fns vs macros, etc you can get from the clj-kondo analysis: https://github.com/clj-kondo/clj-kondo/blob/master/analysis/README.md 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

borkdude20:04:26

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

borkdude20:04:05

a tool like grasp can help you find certain patterns in clojure code, if that's interesting: https://github.com/borkdude/grasp

borkdude20:04:54

This tool uses clj-kondo's analysis extensively to show dependencies between vars: https://github.com/benedekfazekas/morpheus

fadrian20:04:35

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.