Today I had a major slamming-head-into-desk moment, after having wondered for a while why the code wasn't quite as clever as I thought it should be. 😅 Maybe it would be interesting for clj-kondo to help me avoid being this stupid in the future? 🙈
(or option1 option1)
In case it is not clear, this was supposed to be
(or option1 option2)
🙈:redundant-argument could be a linter. applicable to or and
merge possibly more?
but not sure how common this is...
you'd also have to account for side-effecting functions, like (or (.next iter) (.next iter)) . Or just only apply the warning for simple var args, but then that limits its usefulness even further
I was thinking just symbols, but yeah that doesn't seem very useful
how do i make clj-kondo only lint a given language in cljc files?
{:cljc [:clj]}thank you
no sorry: {:cljc {:features [:clj]}}
That's not listed anywhere in doc/config.md. Would you accept a PR to document it?
yes
Is there a way to have any :info level warning fail kondo? i believe i can change a linter's level on a case by case basis, but i was wondering if i could default fail on an info level warn?
You could always parse the output of clj-kondo to detect the info level and return a different status code?
% clj-kondo --lint common/test/scratch/common_test.cljc | tee - >&2 | if grep -E '^[^ ]*: (error|warning|info):' >/dev/null; then echo error ; exit 1 ; else echo success ; exit 0 ; fi
common/test/scratch/common_test.cljc:2:98: warning: #'clojure.test/are is referred but never used
common/test/scratch/common_test.cljc:2:98: warning: #'cljs.test/are is referred but never used
linting took 15ms, errors: 0, warnings: 2
error
if you ran it something like that then you'd get a different exit code for info messages. Not sure if that's any better than the solution you already have, but it might need less upkeep?no, by definition info is a non-failure
ah, is there a way to raise all info linters to warning without explicitly naming them?
i was trying to get to a point where I have to action all linters that have output in our CI system and by default I want to deal with linters that default to info level
nope, not possible, be explicit
thats a shame as i think that means i have to either keep eye-balling the output of kondo for info that i would like to fail on, or stop reporting on info and so lose awareness of new info level linters
we could perhaps support --fail-level info but it sounds wrong to me ;)
yeah conceptually i think i want to raise those info level linters to warning, and only explicitly downgrade them to info when i think they aren't important
exactly
i think my best way forward is to raise to warning the existing info level linters and just keep an eye out for new info ones to either raise or ignore
you can get all linters from here: https://github.com/clj-kondo/clj-kondo/blob/071e557f9dce447953db7ff96929b92d283c4462/src/clj_kondo/impl/config.clj#L21 it's officially an implementation detail but perhaps I could expose an officially supported linter map so you could programmatically do this or so
but there are --fail-lever and --report-level already.
--fail-level info will force kondo to exit with a non-zero exit code.
--report-level doesn't affect the exit code AFAIK. --fail-level only supports warning and error, it's documented
nevermind, info is not supported by fail-level
i think having programmatic access to the linter map would be good as that would allow me to have a CI job that would fail if an info level linter came into existence that i wasn't either raising or ignoring
i guess i can just do that now with the "unofficial" default-config you pointed out
sure