This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-07-12
Channels
- # aleph (5)
- # announcements (1)
- # asami (29)
- # babashka (2)
- # beginners (36)
- # biff (1)
- # cider (6)
- # clj-kondo (29)
- # clj-together (5)
- # clojars (21)
- # clojure (11)
- # clojure-austin (5)
- # clojure-czech (1)
- # clojure-europe (23)
- # clojure-hk (1)
- # clojure-italy (1)
- # clojure-nl (1)
- # clojure-uk (1)
- # clojurescript (38)
- # clojurewerkz (1)
- # cursive (10)
- # data-science (2)
- # datalevin (15)
- # datomic (8)
- # duct (5)
- # emacs (36)
- # events (4)
- # fulcro (7)
- # garden (1)
- # gratitude (1)
- # interop (4)
- # introduce-yourself (1)
- # leiningen (1)
- # missionary (3)
- # music (3)
- # nbb (4)
- # off-topic (21)
- # polylith (6)
- # remote-jobs (5)
- # shadow-cljs (19)
- # specter (4)
- # xtdb (4)
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)
~x))
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?Ah right. For this case the :macroexpand
hook maybe be best.
https://github.com/clj-kondo/clj-kondo/blob/master/doc/hooks.md#macroexpand
https://github.com/clj-kondo/hooks-workshop-clojured-2022/blob/main/part-2/README.md
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)
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
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
no ns-local config to add the lint-as?
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.
What's the actual data you're trying to get? Which arity is being invoked by any given invocation of the function?
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.
arglists is provided but optional data. See https://github.com/clj-kondo/clj-kondo/blob/master/analysis/README.md#extra-analysis
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.
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.