clj-kondo

borkdude 2026-05-22T19:51:01.570789Z

I'm reviewing and improving a PR for a linter that is called :conditional-build-up

(let [m {} m (if whatever (assoc m :foo :bar) m)] ..)
-> 
(cond-> {}
  whatever (assoc :foo :bar))
I don't like the name of the linter. Suggestion: cond->candidate: it conveys that this pattern can be rewritten as cond-> Better suggestions welcome in 🧡

borkdude 2026-05-23T10:36:09.588609Z

decided to go with the existing name since none of the alternatives were compelling

πŸ‘Œ 1
yannvahalewyn 2026-05-22T20:31:06.929839Z

IMO I’d look for something without the condβ†’ prefix as this would be used with a range of names. :conditional-thread-first and :conditional-thread-last came to mind

borkdude 2026-05-22T20:32:34.615719Z

:cond-> means cond thread first?

yannvahalewyn 2026-05-22T20:33:23.522869Z

Oh sorry, I confused it with :lint-as

borkdude 2026-05-22T20:34:17.545169Z

maybe :let-if-to-cond> . I fear that a good name is very hard to find for this one

yannvahalewyn 2026-05-22T20:37:58.782509Z

Does it only work on unnecessary 'let's or are there other cases as well? Maybe something in the direction of prefer-cond→ ?

yannvahalewyn 2026-05-22T20:39:36.564609Z

Maybe redundant-let-to-cond→

seancorfield 2026-05-22T20:42:06.649739Z

prefer-cond-> would get my vote.

yannvahalewyn 2026-05-22T20:59:16.810889Z

prefer-cond→ is perfectly understandable for me. However I don't see other prefer-* names in the linters. Looking at the linters to try to stay idiomatic it seems they are mostly named after detecting the pattern vs the fix. In that regard I think redundant-conditional-binding might be a good one.

seancorfield 2026-05-22T21:03:01.022739Z

Given that @borkdude has said redundant means "remove", I don't think that fits...?

yannvahalewyn 2026-05-22T21:04:15.036659Z

It does remove the binding, doesn't it?

borkdude 2026-05-22T21:07:44.759329Z

redundant-* means: you can remove it without affecting the program, e.g. (do x) -> x

πŸ‘Œ 1
1
seancorfield 2026-05-22T21:11:01.929889Z

(I am a bit surprised none of the existing linters have prefer...)

βž• 1
yannvahalewyn 2026-05-22T21:15:32.099449Z

:conditional-rebind might also work. The original condβ†’-candidate seems pretty good too honestly πŸ™‚.

borkdude 2026-05-22T21:17:34.314259Z

Maybe that's just because we don't have an existing prefer-* like thing? I have merged if-x-x-y which could be renamed to :prefer-or

yannvahalewyn 2026-05-22T21:18:37.143159Z

have a meta config :prefer-prefer to rename all the linters

borkdude 2026-05-22T21:19:15.837679Z

?

yannvahalewyn 2026-05-22T21:22:36.648429Z

just a joke, I guess it didn't land πŸ˜…

😁 1
seancorfield 2026-05-22T21:22:58.444249Z

:prefer-splint 🀣

πŸ˜› 3
borkdude 2026-05-22T21:27:19.962719Z

I guess I can just go ask AI for a good name then. Bye bye ;)

borkdude 2026-05-22T21:28:14.954939Z

no but seriously, I don't think we have a linter yet that says: you should prefer this function/macro over the other

borkdude 2026-05-22T21:28:44.937799Z

except for :not-empty? perhaps

borkdude 2026-05-22T21:29:11.092569Z

and :not-nil? -> some?

borkdude 2026-05-22T21:29:25.685289Z

but the above pattern is hard to capture in one name

seancorfield 2026-05-22T21:29:28.103199Z

Naming is hard.

borkdude 2026-05-22T21:29:58.696749Z

perhaps prefer-cond-> should be it then. better than :conditional-build-up?

seancorfield 2026-05-22T21:31:28.829309Z

Are the linters mostly named for the thing it finds or the thing it thinks you should do? I suspect the former, based on the names I've seen discussed... ...in which case this should be named for what it finds conditional-build-up or conditional-rebinding or...?

πŸ‘ 1
borkdude 2026-05-22T21:32:51.018799Z

:repeated-conditional-assoc
?

borkdude 2026-05-22T21:34:34.383979Z

(if x (assoc m :foo :bar) m)

==>

(cond-> m x (assoc :foo :bar))
I guess you don't even need to "repeat", but I think this linter now only fired when you do that twice

borkdude 2026-05-22T21:34:56.616229Z

:successive-conditional-assoc
is probably better

πŸ‘πŸ» 1