deps.edn / clj support
c.f. https://github.com/jonase/kibit/issues/197; as a proof-of-concept, I was able to adapt Sean Corfield's snippet for boot to deps.edn fairly easily, but it probably merits a mod to the Kibit documentation as well.
A working example, with relevant parts: https://github.com/eigenhombre/trav/blob/master/deps.edn#L7 https://github.com/eigenhombre/trav/blob/master/lint/kibit.clj#L5
FWIW, I got it working from bash with this one-liner:
clojure -Sdeps "{:deps {jonase/kibit {:mvn/version \"0.1.6\"}}}" -e "(require '[kibit.driver :as k]) (k/external-run [\"src\"] nil)"
I’ve not yet managed to get it to work from within a profile in a deps.edn file, but I suspect it should be doable.
Aha, I was able to get it to work via this profile in my deps.edn:
:kibit
{:extra-deps {jonase/kibit {:mvn/version "0.1.6"}}
:main-opts ["-e"
"(require,'[kibit.driver,:as,k]),(k/external-run,[\"src\"],nil)"]}
Granted this is nearly functionally identical to the example linked above; the only functional difference is that it doesn’t require downloading and caching the lein-kibit dependency. That’s a minor plus, but there’s also the minor minus that this is nearly unreadable.
Still, given that projects using tools.deps can fairly easily use Kibit with this technique without any changes to Kibit itself, it seems like it might be worth adding this to the readme? I’d be happy to contribute such a PR if there’s interest.
Thanks to @matthias-margush for pointing out the using-commas-instead-of-spaces trick to work around shell escaping issues in the CLI tools scripts.
Ah, another downside of the lein-kibit-free example above: it won’t pick up on command-line args like --replace — they’d have to be added explicitly to the code passed to -e which is pretty rigid. So at this point I’m leaning more towards recommending using lein-kibit as in your example, @eigenhombre.
I created https://gitlab.com/tvaughan/kibit-runner as a short-term solution to this problem. (I think it would be better to incorporate this into kibit itself.) From its README:
Add:
:kibit {:extra-deps {tvaughan/kibit-runner {:mvn/version "0.1.0"}}
:main-opts ["-m" "kibit-runner.cmdline"]}
to :aliases in deps.edn.
Run:
clojure -A:kibit
This will run kibit over the current working directory and all of its sub-directories.
To specify one or more different directories, run:
clojure -A:kibit --paths src,test,resources,some/other/path
To pass options to kibit, add -- to the end of the command-line and then add
options to kibit. Like:
clojure -A:kibit -- --reporter markdown
Or:
clojure -A:kibit --paths src,test -- --replace --interactive
@aviflax Please note the ability to pass options to kibit ˆˆˆ. Also, Hi! 👋