Fork me on GitHub
#clj-kondo
<
2022-10-04
>
robert-stuttaford09:10:24

Probably a total non-issue and i'm just being pedantic, but i notice that some linter messages start with a capital letter, and some don't 🙂

borkdude09:10:01

Yes, we moved from non-capital to capital and this is now the preferred style, but changing the old ones might break people's builds

robert-stuttaford09:10:24

aha! no breaking changes or Rich will shuffle your stacktraces

3
lilactown15:10:59

why would a map in :var-usages have nil for :row and :col?

lilactown15:10:30

I've got data like

{:name-end-col 17,
  :name-end-row 24,
  :name-row 24,
  :name a,
  :filename
  "...",
  :alias d,
  :from amperity.web.workflows.workflow.resolutions.plugin,
  :col nil,
  :name-col 14,
  :from-var credentials-page-link-component,
  :arity 3,
  :row nil,
  :to helix.dom}

lilactown15:10:56

in the analysis data

lilactown15:10:19

it's not every usage, but a lot

borkdude15:10:22

This might come from a hook which doesn't propagate location metadata

lilactown15:10:23

ah. we do have a few kondo hooks for helix

lilactown15:10:32

is there an example of how to propagate location metadata?

borkdude15:10:13

when generating the a call, you have to set metadata, e.g. from the outer node

borkdude15:10:48

e.g. (with-meta (list-node ...) (meta node))

snoe15:10:45

That might be a useful warning for hook devs.

👍 1
sheluchin17:10:45

I came across this when running analysis on a bunch of libraries. It is a fairly common thing in the wild.

borkdude17:10:37

What clj-kondo could maybe do is remember the col / row of the parent and report that as a fallback

borkdude17:10:46

(if there is a parent)

sheluchin17:10:20

Actually, I thought I did something to fix that in https://github.com/clj-kondo/clj-kondo/issues/1812

borkdude17:10:14

But this isn't released yet. Perhaps @U4YGF4NGM can try with the master version. I hope to finish this release tomorrow

1
lilactown21:10:18

just tried what's in master f0935686f0c4e5690b0965189a7bb11f85b5510d and i still get nil for :row and :col for the same number of vars

sheluchin21:10:12

Ah, I'm afk right now so can't browse the rest of the kondo source but it looks like the tests I added were only for :var-definitions. I guess usages has a similar problem that was not fixed there.

borkdude21:10:14

I still suspect this to be a hook-specific problem

sheluchin21:10:59

Yeah, it's just many hooks out there currently have this problem. I guess it depends on the use case. If there can be some fallback added that provides better results without fixing every hook that omits meta, it would be nice.

borkdude21:10:15

Issue welcome

sheluchin22:10:48

I can take a shot at a fix in a week or two if no one gets around to it by then.

👍 1
lilactown04:10:22

I'm not sure how to add the line numbers back to the new-opts value

borkdude07:10:45

Issue still welcome

borkdude07:10:49

in case we forget

borkdude20:10:08

I'm working on it already

gratitude 1
🙏 1
borkdude21:10:14

@UPWHQK562 By introducing the fix, I could also revert your change in PR 1813. Can you check if that makes sense? https://github.com/clj-kondo/clj-kondo/compare/fallback-location-for-hooks?w=1 @U4YGF4NGM Could you test with this branch / SHA of clj-kondo?

borkdude21:10:51

That is: SHA 34b751fda59dc1f709f55f04554bbe329d4d4ac1

sheluchin22:10:12

@U04V15CAJ traveling right now so can't do the most thorough review but it looks good. I wonder if you can also simplify the :name-row etc. fields so the logic a few lines below in reg-var! can be consistent.

borkdude22:10:11

ok, I'll continue tomorrow

sheluchin22:10:28

The gist of it is you're moving the fallback logic to a more generic location and giving it the explicit name :fallback-loc?

borkdude14:10:28

I looked at your other (or (:name-row ...) ...) stuff @UPWHQK562 but this was still necessary

sheluchin15:10:15

Alright, it would have been nice to make it consistent but this is still a nice improvement. Thanks for working on this, @U04V15CAJ 🙏

borkdude19:10:07

ok @U4YGF4NGM and @UPWHQK562 I merged the final solution to master now. I already had a similar solution for :macroexpand hooks but I now applied the same solution to :analyze-hook for nodes that don't have a location https://github.com/clj-kondo/clj-kondo/commit/17423d1b90498c4667663bd256056fd38bffc46c Please test

borkdude19:10:00

e556f9c5f53620cc9acb2030257c1461556dab84 would be the best commit to test with

borkdude19:10:12

Let's say, just latest master commit

sheluchin17:10:04

@U04V15CAJ Nice, that looks like a much more elegant overall solution. Looking forward to testing this out shortly.

Darin Douglass17:10:07

is setting {:cljc {:features [:clj]}} still the proper way to lint a bb/clojure namespace?