clj-kondo

Ovi Stoica 2025-08-04T17:27:26.079619Z

Recently I discovered -Dclojure.compiler.direct-linking=true as a perf optimization for your production build, but you need to not have with-redef , set!, alter-var-root! and other friends of theirs used on functions otherwise you risk breaking prod. Is there a clj-kondo linter existing for this? I know I could probably do one myself but just curious if this is standardised

borkdude 2025-08-04T17:39:35.680239Z

not standard, but you can detect those with discouraged-var also you can avoid direct linking by marking the vars with `:reload` :redef or :dynamic

👍 1
Alex Miller (Clojure team) 2025-08-04T17:41:59.823079Z

:redef not :reload

borkdude 2025-08-04T17:43:26.602369Z

thanks

dpsutton 2025-08-04T17:45:43.982399Z

if you apply this i’d be interested to see your measured improvements. I tried this and quickly benchmarked and didn’t see anything so i didn’t try to pursue fixing all the edge cases it introduces. Would love to see measured numbers in the wild

Ovi Stoica 2025-08-04T17:47:17.159279Z

I mean… I just read online it gives 5-15% perf boost so I believed it 😄 . Happy to be pointed to some stress testing resources for this

Alex Miller (Clojure team) 2025-08-04T18:07:35.408029Z

I would also recommend use elide-meta too for perf

Alex Miller (Clojure team) 2025-08-04T18:08:21.300129Z

I have multiple times seen a perf boost, but it really depends of course on your hot paths whether it will

👍 1
Reut Sharabani 2025-08-04T18:36:44.760069Z

hello, I ran into https://github.com/clj-kondo/clj-kondo/issues/2257 when linting a project with generated namespaces. Is there a fix planned? Also - what are the workarounds other than excluding the offending files from output?

✅ 1
Reut Sharabani 2025-08-05T08:01:07.443969Z

I think it has to do with the fact this is in project.clj, and kondo not doing macro expansions, or something like that. I don't have the time to debug this now and I have good workarounds (I fixed the symbol, but excluding the project.clj was also acceptable for me). I was wondering if it's something fixable in kondo somehow (my default is always to add clj-kondo/ignore when it's some edge case but it didn't work this time).

borkdude 2025-08-05T08:02:45.713849Z

project.clj and macroexpansions? what does this have to do with invalid symbols?

Reut Sharabani 2025-08-05T08:26:48.544039Z

I don't have the time to debug this like I said, but it happens when I lint project.clj due to symbols like a/b/c, although lein runs fine (and they use the same reader I assume).

Reut Sharabani 2025-08-05T08:35:31.922439Z

I think this is a minimal example of the difference. This code runs fine but breaks in kondo:

> cat k.clj
'a/b/c

> clj-kondo --lint k.clj
k.clj:1:2: error: Invalid symbol: a/b/c.
k.clj:2:1: error: :quote node expects 1 value.
linting took 5ms, errors: 2, warnings: 0

> cat k.clj | clj
Clojure 1.12.1
user=> a/b/c
user=>
I don't think it's good to use it, as Clojure's states symbols should have a single / , but it does run.

borkdude 2025-08-05T08:42:25.572569Z

"it does run", yes that's the point I was trying to make above. clojure doesn't check this, but the tooling around clojure is built around the assumption that you will not use this. tools.reader will crash. this is used by clj-kondo. but Clojure has its own internal reader which is more "permissive"

borkdude 2025-08-05T08:42:59.938509Z

but perhaps we'll have to fix this anyway so I don't have to have this discussion ;)

borkdude 2025-08-05T08:45:31.751729Z

I'll take a look if this is fixable

Reut Sharabani 2025-08-05T08:45:45.179229Z

ok, just pointing out that I ran into this as well. I fixed it for me but I also think it's valuable to write it here. FWIW I do think it should be checked by kondo, but more like the other linters (with similar controls).

👍 1
borkdude 2025-08-05T08:46:17.059779Z

yes, it makes sense for a linter, doesn't it ;)

borkdude 2025-08-05T08:47:07.568999Z

Thanks for the repro:

$ clj -M:clj-kondo/dev --lint - <<< "'a/b/c"
:1:2: error: Invalid symbol: a/b/c.
:2:1: error: :quote node expects 1 value.

borkdude 2025-08-05T13:18:46.295749Z

@reut.sharabani Good news, I finally fixed it on master. It was a bit more work than I expected, but now it works :)

borkdude 2025-08-04T18:37:28.550919Z

Can you fix the code which generated invalid symbols? It's just not supported by Clojure

borkdude 2025-08-04T18:38:12.204619Z

I mean, it's accidentally allowed in Clojure, but not by all the tooling surrounding Clojure including tools.reader

borkdude 2025-08-04T18:39:07.597789Z

yes, excluding files from output is a good solution there's also a different setting for this, let me check

borkdude 2025-08-04T18:41:18.244319Z

yeah, output + exclude-files is the only option for this

borkdude 2025-08-04T18:42:01.418809Z

another option is to process the directories you're linting using a script or whatever and filter out the generated directory

borkdude 2025-08-04T18:42:14.743479Z

if you're experiencing this via clojure-lsp, there's other options too