This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-20
Channels
- # announcements (1)
- # asami (6)
- # babashka (21)
- # beginners (19)
- # calva (44)
- # circleci (3)
- # clj-http (3)
- # clj-kondo (44)
- # clojure (24)
- # clojure-australia (1)
- # clojure-czech (1)
- # clojure-europe (50)
- # clojure-france (5)
- # clojure-germany (1)
- # clojure-nl (2)
- # clojure-spec (8)
- # clojure-uk (8)
- # clojurescript (161)
- # datomic (4)
- # fulcro (7)
- # graalvm (8)
- # heroku (4)
- # lambdaisland (4)
- # lein-figwheel (5)
- # lsp (48)
- # malli (21)
- # meander (15)
- # off-topic (35)
- # polylith (2)
- # re-frame (21)
- # react (22)
- # reagent (13)
- # reitit (6)
- # remote-jobs (1)
- # reveal (3)
- # ring (3)
- # shadow-cljs (37)
- # testing (2)
- # tools-deps (10)
- # vim (18)
- # vrac (1)
- # xtdb (17)
Is there a shell one-liner to make clj-kondo
return a non-zero exit code on errors only?
use case is using git rebase --interactive branch --exec "clj-kondo --lint ./src"
hehe ok essentially what I was going to write in the script… fair enough 🙂
hmm ok small issue, running that actually terminates your shell… I guess that’s expected
clj-kondo --lint - <<< '(inc 0)'; bash -c "if [ $? -gt 2 ]; then exit 1; else exit 0; fi"
?
oh right, I guess this is better then:
clj-kondo --lint - <<< '(inc)'; if [ $? -gt 2 ]; then false; else true; fi
yeah that works better
thanks 🙇
hmm actually neither of those appear to halt the rebase exec
@rickmoynihan even shorter:
clj-kondo --lint - <<< '(inc)'; [[ $? -lt 2 ]]
again it doesn’t stop the exec
does ;
have the right behaviour?
sorry it should be:
$ clj-kondo --lint - <<< '(inc)'; [[ $? -le 2 ]]
<stdin>:1:1: error: clojure.core/inc is called with 0 args but expects 1
linting took 50ms, errors: 1, warnings: 0
yeah was just looking at that
compare:
$ clj-kondo --lint - <<< '(inc)'; [[ $? -le 2 ]] && echo "we made it"
<stdin>:1:1: error: clojure.core/inc is called with 0 args but expects 1
linting took 43ms, errors: 1, warnings: 0
with:
$ clj-kondo --lint - <<< '(inc 2)'; [[ $? -le 2 ]] && echo "we made it"
linting took 12ms, errors: 0, warnings: 0
we made it
hmmm that still doesn’t seem to work 😕
not when I run like this though:
git rebase --interactive clj-kondo --exec "clj-kondo --lint ./src; [[ $? -le 2 ]]"
the issue may have been that $?
would interpolate inside double quotes... you'd want single quotes to delay that in this instance
I’ve dropped a commit in the middle of a bunch that has a deliberate syntax error
and it doesn’t stop on it :thinking_face:
I don't know how bash and git rebase interact but at this point I give up and write babashka
putting it in a script works fine as you’d expect
Perhaps an extra arg to clj-kondo to make all warnings return 0
would be a useful addition?
--allow-warnings
or something?
--fail-on warning
--fail-on error
--fail-on
seems better
Cool… I’ll maybe create an issue for it first
bozhidar We have something like this, let me look it up.
[4:15 PM] It's fail-level -
[4:16 PM] I think that's pretty common across linters.
https://github.com/clj-kondo/clj-kondo/pull/1261 Let me know if you want any changes