Fork me on GitHub
#clj-kondo
<
2022-05-19
>
Nick McAvoy13:05:41

Hi there. A quick suitability check, if you don't mind. The third argument to function foo in our codebase is either a string literal, or a variable which is a string literal, or a value out of a map literal. In other words, if you're reading the source, you can figure out the whole universe of strings passed for this argument; nothing is determined at runtime. Can clj-kondo be used to enumerate the set of strings passed to foo? At first glance, I see some information about arguments is available, but it doesn't seem like something of this sort would be.

borkdude13:05:50

Hi @U01BA210C7K! Do you mean, implement a custom linter, or just have clj-kondo spit out some information separately from using it as a linter?

Nick McAvoy13:05:58

The latter - the information is valuable for a purpose different than linting.

Nick McAvoy13:05:22

I started out looking into tools.analyzer, but wondered if that might be overkill

borkdude13:05:27

Can you give an example of a string coming from a variable or map?

borkdude13:05:43

Based on that I might have different options for you

Nick McAvoy13:05:10

(def bar "bar")

(foo arg1 arg2 bar)
(def foos {:baz "baz"})

(foo arg1 arg2 (:baz foos))

Nick McAvoy13:05:31

I'm afraid I must now turn in for the night - currently I'm in South Korea. I'll be back online tomorrow. Thanks so much for your quick response here, and for your help!

borkdude13:05:34

OK, come back tomorrow and then we'll talk more

borkdude13:05:40

Just ping me here

borkdude13:05:43

Currently clj-kondo doesn't emit any literal values used as arguments, but I was thinking that grasp may help here: https://github.com/borkdude/grasp