This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-05
Channels
- # announcements (2)
- # babashka (23)
- # beginners (67)
- # biff (4)
- # calva (19)
- # cider (6)
- # clj-kondo (40)
- # clj-yaml (14)
- # clojure (3)
- # clojure-austin (13)
- # clojure-europe (18)
- # clojure-nl (1)
- # clojure-norway (26)
- # clojure-uk (5)
- # clojurescript (42)
- # datascript (2)
- # datomic (6)
- # emacs (32)
- # graalvm (8)
- # humbleui (12)
- # hyperfiddle (13)
- # jobs (5)
- # lambdaisland (1)
- # lsp (18)
- # malli (15)
- # off-topic (20)
- # overtone (1)
- # pathom (5)
- # pedestal (15)
- # portal (3)
- # reitit (13)
- # releases (1)
- # remote-jobs (1)
- # yamlscript (4)
Is there a way to add verbose output showing every file that kondo is linting? I have a project with a somewhat odd directory structure below src and test and am not entirely convinced I'm linting every file from the --lint src test
at the root. Any ideas on how to report everything kondo has checked?
Thank you, I did try that but that now seems to indicate it's not linting anything? I get a linting took message with 0 errors/warnings but no other output. Related, I wonder if that status message should also indicate the number of files processed? Anyway I will try and diagnose how to get it to process something
the EDN output might have the number of files:
clj-kondo --lint src test --config '{:output {:format :edn}}'
$ clj-kondo --lint src test --config '{:output {:format :edn}}' | jet -t ':summary :files'
74
Thanks that is helpful. Oh... I'm getting different output if it's clj-kondo directly (which I think is stuck back at 2023.09.07 for me), vs the project level kondo install which is 2023.12.15. clj-kondo --lint src test
correctly finds errors, but clj -Mclj-kondo --lint src test
is not.
My corresponding deps.edn alias is:
:clj-kondo
{:extra-deps {clj-kondo/clj-kondo {:mvn/version "2023.12.15"}}
:main-opts ["-m" "clj-kondo.main"]}
With the deps.edn kondo, if I specifically ask it to lint one file it will process it, but doesn't seem to be searching the directories correctly?Oh and this may be limited to the project I was having trouble with, which is quil, which has a mixture of src/{clj,cljs,cljc}/quil
namespaces, as well as src/quil
and test/quil
. Did something change late this fall on how clj-kondo searches for files?
$ clojure -M:clj-kondo --debug --lint src/cljs/quil/sketch.clj
[clj-kondo] Linting file: src/cljs/quil/sketch.clj
linting took 53ms, errors: 0, warnings: 0
$ clojure -M:clj-kondo --debug --lint src/cljs/
linting took 3ms, errors: 0, warnings: 0
$ clojure -M:clj-kondo --debug --lint src/cljs/quil/
linting took 3ms, errors: 0, warnings: 0
$ clojure -M:clj-kondo --debug --lint src/cljs/quil/*
[clj-kondo] Linting file: src/cljs/quil/sketch.clj
[clj-kondo] Linting file: src/cljs/quil/sketch.cljs
src/cljs/quil/sketch.cljs:4:14: warning: namespace goog.dom is required but never used
src/cljs/quil/sketch.cljs:6:14: warning: namespace goog.style is required but never used
src/cljs/quil/sketch.cljs:17:28: error: Unresolved symbol: rendering-modes
src/cljs/quil/sketch.cljs:17:44: error: keyword :java2d is called with 3 args but expects 1 or 2
src/cljs/quil/sketch.cljs:101:9: warning: unused binding features
linting took 136ms, errors: 2, warnings: 3
vs
$ clj-kondo --debug --lint src/cljs/quil/
[clj-kondo] Linting file: src/cljs/quil/sketch.cljs
[clj-kondo] Linting file: src/cljs/quil/helpers/tools.clj
[clj-kondo] Linting file: src/cljs/quil/sketch.clj
src/cljs/quil/sketch.cljs:4:14: warning: namespace goog.dom is required but never used
src/cljs/quil/sketch.cljs:6:14: warning: namespace goog.style is required but never used
src/cljs/quil/sketch.cljs:17:28: error: Unresolved symbol: rendering-modes
src/cljs/quil/sketch.cljs:17:44: error: keyword :java2d is called with 3 args but expects 1 or 2
src/cljs/quil/sketch.cljs:101:9: warning: unused binding features
linting took 30ms, errors: 2, warnings: 3
Right but my clj-kondo install is 2023-09-07, vs the deps one is 2023.12.15. I tried swapping to extra-deps, replace-deps and just deps for the examples above and was still not finding any files. I'm not quite following -M:clj-kondo example, as I did include the colon. Give me a minute and I'll send you the branch to peruse at your leisure, thanks so much.
I see, you missed the colon in an earlier message https://clojurians.slack.com/archives/CHY97NXE2/p1704485900818259?thread_ts=1704485290.091419&channel=CHY97NXE2&message_ts=1704485900.818259
Yea I'm fixing the other locations it's missing a colon, but the examples above were using a colon and had same behavior. Will re-verify with everything updated though before sending you the branch.
I don't have the --debug line in the script run on CI (and there are other errors that are unrelated), however if you checkout quil on that branch it should replicate the problem I was having with it skipping most of the files.
Thanks again. Separately, that colon/no-colon issue I keep getting confused about, I feel like sometimes it works anyway, but I'm not sure why when it fails. I'll have to bug the deps.edn folks about it at some point as it feels like a documentation issue but maybe I'm just missing something. Thanks for calling that out though.
gotcha
one confusing recent addition to the deps CLI is that -Ttool and -T:tool mean two different things
Yea I had encountered it in -T so that makes sense, just wasn't sure why. Thanks again so much.
One more datapoint. I checked out the branch on my laptop instead of my desktop to see if it was something on that machine somehow, and encountered the same behavior. Then I remembered I did have an alias for clj-kondo in my ~/.clojure/deps.edn
and so I disabled that and still found the same behavior. However, as one last check, I tried my local copy of clj-kondo the binary which is v2023.10.20
, and that has the same behavior as the deps.edn reference, ie it's not finding any files in src unless I specifically list them one by one.
I get the same results with both the newest clj-kondo binary and the JVM version - very weird
So maybe something changed in how files are iterated over between 2023-09-07 and 2023.10.20?
I can debug this by checking out clj-kondo and use it as a local/root dependency (feel free to try if you are curious, will do myself tomorrow)
oh interesting, well, that certainly at least gives a quick fix, and yep can confirm that works here too. Thanks for checking all this, I was having that sensation with software where you are uncertain how very many things work due to a bug that feels hyper-localized. That crazy feeling when software works almost how you expect, but has some little edge case that makes everything else feel like it might unravel. Anyway, very happy to hear that it's not a bug that only occurred on my machines, and happy to have a workaround, I suspect will need a .clj-kondo/config anyway.
(also thank you very much both for your assistance today, and all your work on kondo and many other tools)
if I have something that works just like reg-sub (registers a global keyword that can then be used with another function to look up the current value of that keyword) does clj-kondo have tools to build my own linter for it?
if you use :lint-as
with the re-frame stuff, and it works the same syntactically, I think it should work.
perhaps you can clarify your use case by giving some code
here's an example:
(defflag :foo "Enable feature 'foo'")
(feature-flag? :foo) ;; looks up if flag `:foo` is on and returns true/false
do you mean, you want to navigate from :foo
in feature-flag? to the defflag
? yes, this is possible, let me look it up
it's a bit cryptic but it's here:
:reg: can be added by :hooks using clj-kondo.hook-api/reg-keyword! to indicate a registered definition location for the keyword. It should be the fully qualified call that registered it.
https://github.com/clj-kondo/clj-kondo/blob/master/analysis/README.md
also here:
reg-keyword!: indicates that a keyword's analysis should be marked as a definition. Expects the keyword node and either true or the fully-qualified function that registered it. This can be used to implement keyword navigation for clojure-lsp.
https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md
if you write a hook which wraps the keyword in a reg-keyword!
call (the exclamation mark is misleading, the return value should be used, then it should work with clojure-lsp