Fork me on GitHub
#clj-kondo
<
2024-08-01
>
borkdude09:08:18

In the next clj-kondo version:

clj-kondo 3
🎉 3
borkdude10:08:52

Also a nice addition for the analysis (lsp): @inc wasn't previously recognized as a call to clojure.core/deref, now it is cc @UKFSJSM38

🎉 1
clojure-lsp 1
Thierry12:08:19

Thanks for the update! Came back from vacation to see linting took 4652ms, errors: 972, warnings: 7 haha :face_with_hand_over_mouth: Using mount.lite with @ to deref the defstates it creates.

Thierry12:08:20

<@U04V15CAJ> is there an exclude option for _`:type-mismatch` ? I tried, but doesn't work. `<http://mount.li|mount.li>_te/defstate` is linted as `_clojure.core/_def` but is of type `mount.lite.State` . State is a record of protocol IState, this record also contains IDeref. You can deref it to retrieve the contents.

Thierry12:08:29

Example: _(*deref* db/_datasource_)_ / @db/datasource returns: _{:datasource #_object _[_com.zaxxer.hikari.HikariDataSource 0x30975b87 "HikariDataSource (HikariPool-1)"_]}_ This gets flagged by clj-kondo with: Expected: deref, received: map.clj-kondo(type-mismatch)

borkdude13:08:37

can you make a small repro and file an issue?

borkdude13:08:48

yes, you can override type mismatch:

{:linters {:type-mismatch {:namespaces {'clojure.core {'deref {:arities {1 {:args [:any]}}}}}}}}
from the top of my head

Thierry13:08:16

Thanks, I will try and will make an issue with repro for you

borkdude13:08:06

I think the issue might have arisen from the hooks which make clj-kondo think defstate returns a map, possibly: https://github.com/aroemers/mount-lite/blob/2.x/resources/clj-kondo.exports/functionalbytes/mount-lite/hooks/lite.clj

Thierry13:08:05

In some cases it indeed can return a map

borkdude13:08:16

The point isn't what happens in reality, but what clj-kondo thinks is happening, due to those hooks

borkdude13:08:02

you can also try to override the type of defstate:

{:linters {:type-mismatch {:namespaces {'mount.lite {'defstate {:arities {:varargs {:ret :any}}}}}}}}

borkdude13:08:25

if that works, perhaps it's best to move that to mount.lite

Thierry14:08:57

will do, you are so fast. I was still figuring out how to create a repro

Thierry14:08:31

I tried both linter options, neither work

Thierry14:08:32

linting took 5893ms, errors: 0, warnings: 0

Thierry14:08:38

Thanks, that worked like a charm

borkdude14:08:58

Perhaps you can make a comment in that PR to say that it worked for you

1
Thierry14:08:27

I was just finishing typing exactly that

Thierry14:08:54

Maybe @U050RCD9L can merge the PR and do a release?

Thierry14:08:22

Had to make a quick override hook to fix the default hook resetting

borkdude14:08:10

yeah you could do that as well for now

imre11:08:40

Linter idea: ability to put minimum version of clj-kondo into config and fail when checked by an older version of clj-kondo. Perhaps add as part of the clj-kondo config linter?

❤️ 3
borkdude11:08:34

yeah, good idea. issue welcome

imre11:08:50

sure gimme a few mins

borkdude11:08:31

there's a similar mechanism in babashka for the version comparison etc, probably that code can be borrowed/copy-pasted

borkdude11:08:50

in bb it's called :min-bb-version in bb.edn

imre11:08:05

yep, that's where the idea came from

imre11:08:33

I added a bit about detecting outdated bin from the linter names in the config

imre11:08:11

oh that's actually covered by the current linter

imre11:08:41

I wonder if that only works on the very file or the aggregate?

Stig Brautaset12:08:13

This would be very welcome. I was confused why a check was failing in CI when it passed locally, and it turned out to be exactly this: CI version of clj-kondo was older than my local one.

imre12:08:46

give it a 👍:skin-tone-3: so 🙂

👍 1