Fork me on GitHub

I'd like to store the analysis data in a sql db. Is this already being done somewhere? I'd like to use a standard/common schema for it, if there is one.


There is no sql stuff yet. I'm playing around with some SQL stuff where you can store analysis of multiple projects, but there's nothing finished about it. If you've got something useful to share at some point, please do :)


Thanks @U04V15CAJ, will do :)


I recently wrote this macro:

(defmacro when->
  "If bool is true, return (-> x form). Otherwise, return x unchanged.
   Useful in threading, e.g. (-> {:a 1} (when-> something (assoc :b 2)))"
  [x bool form]
  `(if ~bool
     (-> ~x ~form)
When I try to use it though, clj-kondo complains. For example:
(-> m
    (when-> (some-test (:k1 m)) (assoc :k2 5)))
;; clojure.core/assoc is called with 2 args but expects 3 or more - clj-kondo (invalid-arity)
How do I get clj-kondo to stop complaining?


Are you familiar with lint-as?


A little, what would I lint when-> as though? It takes different args from ->


You can basically copy / paste your macro in the config. If you have loss of too many locations, then the :analyze-call hooks is the best option (which isn't too hard for this macro)

Cora (she/her)16:07:25

definitely what @U04V15CAJ said 😅


Is there a way to do it inline, like with metadata or a comment? This is a huge monolith so it feels a little icky to change the entire thing's kondo file for my one local helper macro

Joshua Suskalo17:07:25

Potentially you could lint it as as-> if it isn't too strict about the argument being a symbol


> Is there a way to do it inline, like with metadata or a comment? No. But perhaps if it's only used very locally, then you can just suppress the linting in it

Joshua Suskalo17:07:26

no ns-local config to add the lint-as?


for lint-as yes, but not for the hook


TIL about #_{:clj-kondo/ignore [:invalid-arity]}, thanks!


I think cond-> would give you the same as your when->

☝️ 1

Is there a way to get function call argument information? The way I can think of is to look up the var usage in var definitions and try to match the arity count in case of a variadic, then check the definition's :arglists.

Joshua Suskalo19:07:11

What's the actual data you're trying to get? Which arity is being invoked by any given invocation of the function?


I'd like to be able to get the argument names being used in a function call.

Joshua Suskalo20:07:45

Then yes, you should be able to look at the arglists metadata from kondo's analysis, but I do want to ask @U04V15CAJ if arglist metadata is automatically populated in analysis. I expect not, in which case you'll have to look at the different arity's argument vectors manually if arglists is not provided.


Yes, saw that part. In my case I'm looking for the arglists on function invocations, not just definitions. I'll make the connections manually if there isn't some convenience flag or function for it.


Ah right, you want the join on the definition


Yeah, right now some things are "joined" automatically, like arity info


But not all of it, to save some data size


Yep, join on definition sounds like what I'm after. So in some cases it is already joined? Could you please mpoint me to the function which does the joining so I can get the full list in case of omissions?


@U04V15CAJ thanks very much.