Fork me on GitHub
#clj-kondo
<
2021-03-24
>
borkdude10:03:37

@robert-stuttaford Please move the question as a Q/A here: https://github.com/borkdude/edamame/discussions/categories/q-a We can continue the discussion over there, as this doesn't really belong in this channel

👍 3
snoe20:03:13

it seems kondo does some sort of deduplication of findings. is there a way to output findings for the duplicates?

$ printf "foo\nfoo" | clj-kondo --lint -
<stdin>:1:1: error: unresolved symbol foo
linting took 35ms, errors: 1, warnings: 0

borkdude20:03:13

@snoe clj-kondo only outputs the first unresolved symbol as to not flood users with the same type of warning

borkdude20:03:34

this also ties into #_:clj-kondo/ignore: ignoring the first one, ignores all the next unresolved symbols of the same name

snoe20:03:21

is it possible to turn that off? it's really annoying in the editor to play whack a mole, fixing the first and having the second pop up.

snoe20:03:59

makes a lot of sense from the command line, but maybe the count of 1 error is misleading in the same way (with a flag obvs)

borkdude20:03:03

It's currently not possible. I have discussed this with @ericdallo before as well and I suggested making an option for this in the unresolved-symbol linter

snoe20:03:40

gotcha, sorry must have missed it. Is it only that linter that ignores?

borkdude20:03:32

no, but the ignore is applied to a later phase then where the unresolved findings are emitted, so when you ignore the first one, the other part of the code still thinks there is one, let's say

borkdude20:03:22

let me point you to the code

borkdude20:03:44

sorry, gotta go for a half an hour first

👍 3
borkdude20:03:24

so what happens: https://github.com/clj-kondo/clj-kondo/blob/76143d350946c18cd3ffc425b35aa01a6c78561d/src/clj_kondo/impl/namespace.clj#L267 unresolved symbols are kept in a map. when there is already one in the map, it is not overwritten (as to not generate multiple) I copied this behavior from joker and personally I liked it but I'm open to optionally change it

🙏 3
borkdude20:03:34

(now afk for a bit)

borkdude20:03:10

we could e.g. change the map values to vectors

borkdude20:03:29

and by default only report the first one

snoe21:03:56

would you like to keep the overwriting from a perf perspective?

snoe21:03:38

Another question, where would you like the config flag? {:skip-duplicates true} alongside skip-args feels right but it seems like only unresolved-vars and unresolved-symbols has this property so it might feel inconsistent.

borkdude21:03:41

I think the option should go into each linter separately. I think also unresolved-namespace has it. I think it should be something like :report-duplicates true so not having this property defaults to nil

👍 3
borkdude21:03:21

what do you mean from a perf perspective?

snoe21:03:10

I guess there could potentially be a large vector underlying the linter, if report-duplicates is false, it might make more garbage than you're comfortable with.

snoe21:03:35

I'm thinking to your comments about destructuring and such

borkdude21:03:32

Ah, right. I think unresolved-symbols are the unhappy path, there should be relatively few of them, so I think that would be ok

snoe03:03:30

thanks hopefully the pr is close

snoe03:03:15

i looked at the code for unused-namespace and it doesn't seem like it's deduping, but I could have missed something.

borkdude07:03:10

Unresolved namespace