clojure-europe

reefersleep 2025-10-11T13:31:07.200209Z

What's a good way to find usage of a function in a project programmatically?

reefersleep 2025-10-13T15:17:58.194189Z

It works as intended! Neat 🤓

🎉 1
borkdude 2025-10-13T15:18:43.727669Z

now write a blog about what you did, I'm curious ;)

reefersleep 2025-10-12T08:13:28.469489Z

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.

borkdude 2025-10-12T08:14:23.466859Z

you can probably reduce the "waste" by not analyzing everything or only re-analyzing when something has changed, by hashing stuff or so

reefersleep 2025-10-13T04:49:56.253469Z

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.

reefersleep 2025-10-13T04:51:09.698779Z

@borkdude given I've found files via the above code, can I use clj-kondo to find the namespaces of those files?

👍 1
reefersleep 2025-10-13T04:51:51.448629Z

And also to tell me the namespaces required by a specific file/ns.

reefersleep 2025-10-13T04:52:42.171979Z

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 😁

reefersleep 2025-10-13T04:57:29.231719Z

Ah, I can use :namespace-definitions

👍 1
reefersleep 2025-10-14T07:31:53.649559Z

I'll consider it, it's a nice blog-bite-sized thing

reefersleep 2025-10-11T13:35:37.200999Z

Maybe using clj-kondo? https://github.com/clj-kondo/clj-kondo/blob/master/analysis/src/clj_kondo/tools/find_var.clj

borkdude 2025-10-11T14:09:12.596129Z

yep, that's one way

borkdude 2025-10-11T14:10:31.613339Z

in clojure-lsp you can also do find-references in an editor

reefersleep 2025-10-11T14:31:33.021359Z

Yeah or using Cursive 🤓 I want to do it as a part of a unit test.

borkdude 2025-10-11T14:32:16.048789Z

👍

borkdude 2025-10-11T14:32:24.569219Z

is this for discouraging certain vars?

reefersleep 2025-10-11T14:35:20.233219Z

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.

borkdude 2025-10-11T14:36:08.537899Z

👍

reefersleep 2025-10-11T15:04:16.761889Z

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 🤓

borkdude 2025-10-11T15:04:52.877439Z

wasteful in what sense? :)

reefersleep 2025-10-12T06:18:07.486239Z

Spending lots of I/O and static analysis computation per cicd run on to check on something that rarely changes