What's a good way to find usage of a function in a project programmatically?
It works as intended! Neat 🤓
now write a blog about what you did, I'm curious ;)
I mean, it's not a lot per run, but accumulated vs the frequency of change, it might be a bit silly. But I'm expecting some spikes of change within the next half year, so it might be nice for that period of time.
you can probably reduce the "waste" by not analyzing everything or only re-analyzing when something has changed, by hashing stuff or so
Yeah, just haven't figured out a good dev-ex for discovering changes and updating a hash. But it's something I want to pursue as a general solution for such use cases.
@borkdude given I've found files via the above code, can I use clj-kondo to find the namespaces of those files?
And also to tell me the namespaces required by a specific file/ns.
I can hack together a solution myself, but I figure clj-kondo might have something already that might also be more robust than what I come up with 😁
Ah, I can use :namespace-definitions
I'll consider it, it's a nice blog-bite-sized thing
Maybe using clj-kondo? https://github.com/clj-kondo/clj-kondo/blob/master/analysis/src/clj_kondo/tools/find_var.clj
yep, that's one way
in clojure-lsp you can also do find-references in an editor
Yeah or using Cursive 🤓 I want to do it as a part of a unit test.
👍
is this for discouraging certain vars?
No, it's to discover whether ns'ses using a specific function have not been required in a specific central "registry" ns, as per our current convention.
👍
I think it might be a bit of a wasteful way to achieve the intended result, but it might be a fun experiment in using static analysis with clj-kondo 🤓
wasteful in what sense? :)
Spending lots of I/O and static analysis computation per cicd run on to check on something that rarely changes