Fork me on GitHub
#babashka
<
2023-06-12
>
beoliver10:06:17

Any idea why the following hangs

12:22:25 ~ $ rlwrap bb
Babashka v1.3.179 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (do
  (require '[babashka.pods :as pods])
  (pods/load-pod 'clj-kondo/clj-kondo "2023.04.14")
  (require '[pod.borkdude.clj-kondo :as clj-kondo])
  (with-in-str "(x  )" (clj-kondo/run! {:lint ["-"]}))
  )
0% cpu usage. The with-in-str was taken from https://github.com/clj-kondo/clj-kondo/blob/c0a6b525d89f32a648fa044e78cfc2dcbbaef94d/test/clj_kondo/core_test.clj#L64

borkdude10:06:44

This particular thing doesn't work with the clj-kondo pod

borkdude10:06:54

since stdin of the host process isn't connected to the pod

borkdude10:06:05

you can maybe use a temporary file to lint a random string

beoliver11:06:17

Ah ok thanks. Yes I had tried with a temporary but wasn’t sure if it was possible to set an explicit filename so as to avoid the ns warning. My understand is that it is only when "-" is used that the value of :filename is checked. Concretely, I have a little babashka script that computes which linting errors have been introduced in any staged and unstaged commits. I then compute which current lines in a file have new linting errors. Currently I just stash everything and then run clj-kondo before unstashing and linting again before compating results. This is fine, and lets me avoid any temp files. https://github.com/beoliver/diff-lint/blob/master/diff_lint.clj However, I occurred to me that the following approach would let me get the linting results “pre changes” and avoid having to git stash

git --no-pager show HEAD:src/some/file.clj | clj-kondo --cache false --filename $(pwd)/src/some/file.clj --lint -
and then run clj-kondo on some/file.clj .

borkdude11:06:42

I think we could have a better way to lint a string of code in the clj-kondo API possibly

borkdude11:06:05

issue welcome

👍 2