clj-kondo

2024-08-20T13:48:00.190599Z

I have a question about usage of clojure.pprint vars in public code. i know clj-kondo can do usage analysis, is that documented somewhere?

borkdude 2024-08-20T13:54:31.858059Z

Yes, check analysis/Readme.md

2024-08-20T13:55:56.679239Z

excellent, thank you

2024-08-20T15:41:04.506989Z

burned myself the other day with a stupid mistake, was thinking maybe it could be a linter given repro.clj:

(ns repro)

(defn x [& _]
  "y")

(println x "z")
run:
$ clj -M repro.clj
repro$x@11963225 z
usually (always?) I'm trying to call a function to get a value in a string, and not get the string of the function definition. but it might depend on the project worth opening a feature request issue for this?

borkdude 2024-08-22T15:54:53.291079Z

yes, I was talking about functions that do explicitly want a string, like str/includes?, println isn't such a function

borkdude 2024-08-20T15:43:00.951819Z

I'm not sure how this would work in general. It's not always immediately clear that passing a function as value rather than calling it is mistake, unless the function you're passing it to explicitly wants a string

2024-08-20T15:43:58.103759Z

yeah I was thinking, anything that explicitly wants a string

2024-08-20T15:54:17.038399Z

or more generally: a function being passed to anything known to be not callable seems more like a type check than a linter idk how feasible it'd be to check if a function reference is used anywhere a string/number/etc. type is expected

borkdude 2024-08-20T15:55:31.437519Z

this should already be caught by the linter as a type mismatch. e.g try passing a function to e.g (str/includes? f ...)

👍 1
2024-08-21T03:38:01.381599Z

The println docs point at print, and print explicitly says it prints objects, not strings

👆 1
2024-08-21T03:38:38.609899Z

println is not a function that explicitly wants a string