clj-kondo 2026-07-18

With the latest Kondo, I have a false positive but I understand why Kondo may not be able to figure this out: (render-report data nil) is warned that Expected: number, received nil on that second argument. Inside render-report, there's this local fn, which is where Kondo gets the "number" usage:

avg-out   (fn [row]
                    (reduce (fn [row col]
                              (update row col / (double average)))
                            row
                            [:sent :viewed :clicked]))
However, avg-out is only used if average is non-`nil`:
:report/totals  (cond-> totals
                                         average
                                         (avg-out))
There are probably several ways I can change the code to satisfy Kondo here, but I wanted to see whether this is considered a bug in type inference/flow first?

Changing the local fn binding to this satisfies Kondo:

avg-out   (when average
                    (fn [row]
                      (reduce (fn [row col]
                                (update row col / (double average)))
                              row
                              [:sent :viewed :clicked])))
Which is quite impressive (in terms of Kondo figuring that out), and probably better from a defensive coding p.o.v.)

right, so it's behind a conditional. thanks for this case, I'll make clj-kondo not register this when the function is called in a conditional or I'll maybe scratch registering arg specs from inner fn usages completely

👍🏻 1

@seancorfield This is now fixed on master. "Evidence" from an inner function only counts when it can be proven that that inner function is executed and it's not within a conditional

👍🏻 1