clj-kondo

https://github.com/clj-kondo/clj-kondo
souenzzo 2020-08-28T17:42:59.031Z

Do kondo "evaluate"/"understand" clojure.spec in some way? can it lint things like

(s/def ::f (s/nilable fn?))
(let [{::keys [f]} env]
  (f))
You can'f call 'f' because it may be 'nil'

borkdude 2020-08-28T17:51:51.032200Z

@souenzzo I'll paste something out of a conversation I had in #clojure-spec:

Slack: borkdude: Yes. spec is a runtime validation/conformation/generation library. And considering how complex core.typed gets, I don't think getting leverage out of specs at compile time is trivial. Using a tool for something it's not designed for in general is ... hard.

Slack: borkdude: I do think you can get &lt;some&gt; leverage out of it. E.g. a tool could inspect specs at runtime, parse out the trivial stuff like, is the first argument an int?? Then something like <https://github.com/borkdude/clj-kondo/blob/master/doc/types.md> can be generated and you will get &lt;some&gt; static analysis benefits for clj-kondo, for example.

borkdude: Malli / @ikitommi has demoed a similar approach at ClojureD.

jahvenni: Yeah, figuring out the trivial stuff is what I had in mind mostly. I can see many trivial cases where a linter utilising specs could easily provide value. Things like order of parameters, names of keyword arguments or tricky get-in's are mentally really heavy for someone who is used to have these things given by autofill. To me these sound like trivial things to check in most cases if spec is provided. It would be a much softer landing to a dynamic language.

πŸ‘ 2
ikitommi 2020-08-28T17:54:27.032400Z

πŸ‘ 1
🀘 2
ikitommi 2020-08-28T17:54:47.033100Z

here’s the prototype from clj-kondo + malli

borkdude 2020-08-28T18:19:31.033700Z

Just merged support for linting in parallel which can give significant speedups when you are linting an entire classpath. https://github.com/borkdude/clj-kondo/issues/632

πŸ‘ 1
πŸŽ‰ 1