Fork me on GitHub
#clj-kondo
<
2023-05-03
>
dominicm09:05:45

Is it expected that using :lint-as def-catch-all will not set :defined-by in :var-definitions?

borkdude09:05:10

let's continue in thread

šŸ‘ 2
borkdude09:05:43

it may or may not be by design, we can change it and see what tests are breaking :)

borkdude09:05:59

or we could add another key in the analysis

borkdude09:05:25

some parts in clj-kondo rely on defined-by, so if you lint-as def than that may give you behavior that you would not get otherwise

borkdude09:05:27

but maybe this should change

dominicm09:05:56

I did stumble on an issue from 2021 about including context in analysis, maybe relevant?

dominicm09:05:05

Benedek was looking at reframe stuff.

dominicm09:05:40

I suppose that would be very chatty though, for this use.

borkdude09:05:41

that's something else, has to do with keywords

borkdude09:05:59

can you post an issue about this?

borkdude09:05:06

I'll take a look before the next release

dominicm09:05:12

For sure, thanks!

dominicm09:05:07

Equally annoying, using :lint-as {ns/<> clojure.core/def} will set :defined-by to clojure.core/def rather than to ns/<>

dominicm09:05:46

Fwiw, Iā€™m trying to identify uses of is inside of defspec. And this is making it difficult šŸ™‚

šŸ‘ 2
Eduardo Lopes11:05:37

Does it make sense clj-kondo include splint for code shape lint? https://github.com/NoahTheDuke/splint

borkdude11:05:37

I think it has good ideas so maybe some of those ideas could be ported to clj-kondo. The model is a bit different though: it just looks at the shape and not at the resolved var (so you can't distuingish from locals for example) and this could lead to false positives. The most popular of those linters we could maybe just port directly. The matching idea is pretty cool. Including another linter inside of clj-kondo will also negatively affect performance and hence editor feedback, so this would have to be carefully considered.

Eduardo Lopes11:05:14

I've tested it's performance on a "big" project and it took a few seconds for the entire project, linting a single file may be pretty fast. But I didn't tested enough on single files

Eduardo Lopes11:05:19

I didn't get why can't distinguish from locals and lead to false positives, can you explain noob friendly? Some example will help šŸ™‚

borkdude11:05:51

This is explained in the splint readme I believe

Eduardo Lopes11:05:18

That's true I got it

Noah Bogart16:05:02

hi, I built splint. I experimented with this and clj-kondo is tightly coupled to evaluation/scoping, making it hard to find a single point to drop in a call to splint/check-form or similar. I decided to build splint to not over-burden clj-kondo, and given their relative speeds, I don't think it's burdensome to run both; I see clj-kondo as helpful when actively developing, whereas I see splint as helpful after finishing a period of work (before committing or in CI).

borkdude16:05:20

you can do a splint/check-form thing on analyze-expression** where every rewrite-clj expression is passed through, but I'm mostly concerned about the performance hit that this will incur and false positive (so I think I'd rather match on the analyzed stuff than the raw nodes)

borkdude16:05:44

perhaps there is a way to do this, but I haven't found it necessary, as things that I find really important can just be baked into clj-kondo

šŸ‘ 2
borkdude16:05:22

in clj-kondo the matching ("is this thing inside the other thing") is usually implemented by lookup upwards in the "callstack"

Sagar Vrajalal11:05:16

Can I configure clj-kondo to lint files which don't have any ns declarations? Say I have a file src/main/clojure/a.clj

(defn+ ... )
and another file src/main/clojure/b.clj
(ns main.clojure.b)

(defmacro defn+ ...)
I would like to be able to hover over defn+ in a.clj and look at the docstring, arglist, etc. I am using VSCode and Calva. Is this out of scope for clj-kondo?

borkdude11:05:57

how is clj-kondo supposed to know where defn+ comes from?

Sagar Vrajalal12:05:10

It doesn't, but I was wondering if it would be possible through configuration. Something like -> For a specific file, or every file under a specific path, lint it as if its contents were defined in another namespace.

borkdude12:05:28

not possible, just write (require '[some-namespace :refer [defn+]])

Sagar Vrajalal12:05:34

Gotcha, thanks!