clj-kondo

borkdude 2025-01-16T15:58:04.350339Z

https://clojurians.slack.com/archives/C06MAR553/p1737042813783249

3
🎉 6
imre 2025-01-17T13:26:57.141469Z

Hey Michiel, I'm upgrading to this version and also trying out min-version and found a warning that I don't expect:

; echo '{:min-clj-kondo-version "3030-01-01"}' > .clj-kondo/config.edn
; clj-kondo --lint .clj-kondo/config.edn
.clj-kondo/config.edn:1:2: warning: Linter config should go under :linters
:1:1: warning: Version 2025.01.16 below configured minimum 3030-01-01
linting took 47ms, errors: 0, warnings: 2

borkdude 2025-01-17T13:28:01.048409Z

why don't you expect this warning?

imre 2025-01-17T13:28:06.489759Z

.clj-kondo/config.edn:1:2: warning: Linter config should go under :linters

imre 2025-01-17T13:28:15.640119Z

sorry I wasn't specific enough

imre 2025-01-17T13:28:36.057209Z

https://github.com/clj-kondo/clj-kondo/issues/2362 says I should provide the min version as a top-level key

borkdude 2025-01-17T13:28:36.481829Z

ah ok, thanks. never seen this one before. Perhaps you can file an issue?

imre 2025-01-17T13:28:44.592779Z

absolutely

🙏 1
imre 2025-01-17T13:29:22.385429Z

also, would it make sense to perhaps set the location of the actual version warning to the line where the min version is specified?

borkdude 2025-01-17T13:30:37.110529Z

that's a bit harder than it looks since this setting may come from an arbitrary set of merged files that we don't track the origin of

borkdude 2025-01-17T13:30:47.738809Z

this is why it says <clj-kondo> and not <stdin> or whatever

imre 2025-01-17T13:31:41.276649Z

Hmm gotcha. And I suppose it wouldn't make sense to always put it on line one of .clj-kondo/config.edn either, given there might not be an actual config.edn?

borkdude 2025-01-17T13:32:05.843319Z

right

imre 2025-01-17T13:33:06.837039Z

what if it's put there if that file exists (is among the ones being linted) and left like the current one otherwise? usecase: IDE tooling can display an inline squiggly line if there is a file to show it in

borkdude 2025-01-17T13:34:01.031169Z

sounds reasonable, are you willing to provide a PR?

borkdude 2025-01-17T13:36:21.605289Z

optional of course. issue about this is welcome

imre 2025-01-17T13:37:14.235909Z

I might be able to. Let me raise an issue and if you could give me (or someone else) a few pointers there I'll try to find time for it

borkdude 2025-01-17T13:37:34.714589Z

yeah, I could give pointers

borkdude 2025-01-17T13:38:38.886529Z

you'll need to parse the .clj-kondo/config.edn file with rewrite-clj and find the location of the value for the min-clj-kondo-version key, that's mostly it.

imre 2025-01-17T13:42:13.206279Z

https://github.com/clj-kondo/clj-kondo/issues/2463 for the original problem I found

imre 2025-01-17T13:49:08.571339Z

Thanks a mill!

👍 1
borkdude 2025-01-17T13:50:33.884369Z

I think one reason not to implement this is that often IDE users can't immediately update the clj-kondo version (e.g. when you're using clojure-lsp)

borkdude 2025-01-17T13:50:41.921369Z

so this thing is often used in CI only

borkdude 2025-01-17T13:53:27.723319Z

I vaguely remember that discussion, perhaps it's in the related issue when this was implemented

imre 2025-01-17T15:11:50.347069Z

hmm. The original ticket is here https://github.com/clj-kondo/clj-kondo/issues/2362 > often IDE users can't immediately update the clj-kondo version perhaps the proposed behavior could be behind a flag in the linter config? I would want to know when my bundled kondo is too old so I can make a pr/issue/custom build to update it.

borkdude 2025-01-17T15:14:10.490659Z

yeah, let's just do it the way I proposed. there's also some deps.edn-specific linting in clj-kondo so there you can probably look how stuff works as well

imre 2025-01-17T15:17:34.639909Z

for sure, thanks

imre 2025-01-17T15:28:04.814999Z

ah, I just realized version strings should be .-delimited as in versions, not - as in iso dates

👍 1
imre 2025-01-17T15:29:39.817869Z

specifying it properly now reveals that my ide seems to mark the entire config as errory with the current <clj-kondo>:1:1 location

imre 2025-01-17T15:30:12.988639Z

I guess this solves the part that I am notified about it being outdated

borkdude 2025-01-17T15:30:34.153889Z

ah I didn't know that

imre 2025-01-17T15:30:46.446489Z

but I wager it would still be an improvement to focus it onto the value if it's available?

borkdude 2025-01-17T15:31:04.125919Z

I guess this is just because Cursive does something with the warning instead of just ignoring it, dunno

imre 2025-01-17T15:32:05.480069Z

It's clj-extras actually. My guess is that if it cannot locate the warning back to a file it will just mark the entire config

borkdude 2025-01-17T15:32:12.402349Z

yeah

imre 2025-01-17T16:30:11.199919Z

checking the extended discouraged var linter:

; echo '(map inc (range 5))' | clj-kondo --config '{:linters {:discouraged-var {clojure.core/map {:arities #{2, 3, 4, :varargs}}}}}' --lint -
linting took 51ms, errors: 0, warnings: 0


; echo '(map inc (range 5))' | clj-kondo --config '{:linters {:discouraged-var {clojure.core/map {}}}}' --lint -
<stdin>:1:1: warning: Discouraged var: clojure.core/map
linting took 25ms, errors: 0, warnings: 1
why does the first command not give a warning?

imre 2025-01-17T16:31:07.988309Z

; clj-kondo -version | head -n 1
clj-kondo v2025.01.16

imre 2025-01-17T16:36:04.542629Z

no luck this way either:

; echo '(map inc [1 2 3])' | clj-kondo --config '{:linters {:discouraged-var {clojure.core/map {:level :warning, :arities #{1, 2, 3, 4, :varargs}}}}}' --lint -

imre 2025-01-17T16:42:41.776079Z

Seems to work for this case though:

; echo '(partial map inc)' | clj-kondo --config '{:linters {:discouraged-var {clojure.core/map {:arities #{2, 3, 4, :varargs}}}}}' --lint -
<stdin>:1:10: warning: Discouraged var: clojure.core/map
linting took 61ms, errors: 0, warnings: 1

imre 2025-01-17T16:48:29.757979Z

Happy to record an issue if this turns out to not be a user error on my end

borkdude 2025-01-17T18:41:51.148969Z

I'm getting:

$ echo '(map inc (range 5))' | clj-kondo --config '{:linters {:discouraged-var {clojure.core/map {:arities #{2, 3, 4, :varargs}}}}}' --lint -
<stdin>:1:1: warning: Discouraged var: clojure.core/map

imre 2025-01-17T18:42:23.855999Z

Hmm what the hell

borkdude 2025-01-17T18:42:23.875879Z

never mind, my binary is out of date, let me try the JVM version

imre 2025-01-17T18:42:39.948929Z

Thsi is with the brww installed one

borkdude 2025-01-17T18:47:19.007599Z

yeah seems like a bug. also I notice I copy pasted a lint warning about something else which should have been a discouraged var facepalm https://github.com/clj-kondo/clj-kondo/commit/971f90aaf4d9fe6543f0488a8cc6b1541a2cd974#diff-253b0be1bbe77f23a3283f4af26053ac71022a6b6bda2bd39583dc7fc182dadeR121 please mention that in the issue as well

imre 2025-01-17T18:48:26.001289Z

Sure thing

imre 2025-01-17T22:57:50.466229Z

recorded here https://github.com/clj-kondo/clj-kondo/issues/2465

🎉 1
imre 2025-01-17T22:58:32.491629Z

Thank you for the awesome work you do! clj-kondo is an absolute gem.

🙏 1
imre 2025-02-18T13:16:35.619009Z

do you have a rough idea when a new version would be released?

borkdude 2025-02-18T13:18:37.301379Z

I'm in the middle of upgrading graalvm which I'll merge tomorrow but I don't have time the rest of the day, but I could do a release thursday or so.

imre 2025-02-18T13:24:13.212679Z

That would be lovely, I'm looking forward to seeing the recent improvements released. Thank you

👍 1
imre 2025-02-07T18:22:58.166829Z

Submitted PRs addressing #2463 and #2464

borkdude 2025-02-07T19:01:06.115609Z

Thanks, it's on my list to review!

❤️ 1