Fork me on GitHub
#clj-kondo
<
2022-01-15
>
Eugen00:01:23

I'm looking to add a linter for a macro proxy+ - https://github.com/redplanetlabs/proxy-plus . The macro is used to extend java abstract classes. Any hints on how to approach this ? Where can I publish the linting so it's usable by other people when it's done? Sample code: https://github.com/ieugen/ofbiz-tooling-ro/blob/main/development/src/dev/schema.clj

Eugen00:01:58

Seems lint-as works in getting rid of the warnings - will see how this behaves in the future:

(ns dev.schema
  {:clj-kondo/config '{:lint-as {com.rpl.proxy-plus/proxy+ clojure.core/proxy}}}

Eugen01:01:16

Is there a rule for unused this in reify ? I would like to ignore them. Perhaps I can use _

Eugen01:01:14

_ seems to work ok. I'm good, sorry for using Slack as my rubber duck

duckie 1
Alex Miller (Clojure team)01:01:17

this is just a convention, you can call it whatever

borkdude07:01:41

@eugen.stan you can start any name with an underscore, like _this to get it ignored

borkdude07:01:32

There is an issue about an option for ignoring the self referring local automatically, feel free to upvote

Eugen10:01:57

thanks. I will check it out. lint-as for proxy+ does not work that great. hides errors for undefined symbols inside the construct. any hints on how should I go by implementing linting for this? it'similar to reify and proxy, I could not find how those are implemented though

borkdude10:01:46

@eugen.stan You can support any macro by writing a hook for it. The :macroexpand hook is the easiest as you can just place a simplified macro in your config.

borkdude10:01:02

If you have an example of this proxy+ macro I can help you get going.

borkdude10:01:31

An alternative is to just turn off unresolved symbols in calls to proxy+

borkdude10:01:00

:unresolved-symbol {:exclude [(com.rpl.foobar/proxy+)]}

Eugen10:01:38

I tried ignore and clj-kondo threw error

Eugen10:01:59

but syntax was not like above, will try again

Eugen10:01:36

I have a link to my github above, with code image that shows how I use it

Eugen10:01:56

latest commit should contain limiting rule I used

borkdude10:01:03

ok, let's continue in a thread. I'll check out the code and take a look

Eugen10:01:12

thanks, the difficult part IMO is that it references methods from classes and interfaces and that could be anything

borkdude10:01:56

do you have a link to the exact file and line where this is used?

Eugen10:01:02

so a lint-as reify might work for each case where it's implementing an interface or class

borkdude10:01:30

I don't get any errors in this code linked before

Eugen10:01:40

yes, above but can't copy paste it on phone

Eugen10:01:56

it's schema.clj

Eugen10:01:22

in my post from earlier

borkdude10:01:30

$ clj-kondo --lint development/src/dev/schema.clj
development/src/dev/schema.clj:151:24: warning: unused binding parent-schema
development/src/dev/schema.clj:151:46: warning: unused binding name
development/src/dev/schema.clj:151:56: warning: unused binding operand
linting took 59ms, errors: 0, warnings: 3

borkdude10:01:54

commit: 61cf0b033e49d278fb841e86bee3cda694ae2e41

Eugen10:01:19

let me go to computer

Eugen11:01:33

yes, but if I change line 124 to len (- (count undefined-symbol) 1) and run linting I get the same errors as above

Eugen11:01:38

that is inside reify org.apache.calcite.linq4j.Enumerator of enumerator method of proxy+ AbstractEnumerable

borkdude11:01:19

I changed that, but I don't see an error. Are you sure this error is coming from clj-kondo and not from some other tool?

Eugen11:01:56

that is the issue, IMO, we SHOULD get an error and we don't

Eugen11:01:10

undefined-symbol is clearly undefined

Eugen11:01:59

maybe it has to do with nesting ?!

borkdude11:01:21

Yes, this is not an issue with your config, it's an incompleteness in clj-kondo which can be improved. Proxy is one of the few things that I kept postponing to support fully ;)

borkdude11:01:47

Feel free to post an issue. You can reproduce this with normal clojure proxy as well

Eugen11:01:02

ok, will do

Eugen11:01:07

thanks for looking into this

👍 1
Eugen11:01:48

bug report of feature request 🙂 ?

borkdude11:01:35

either is fine ;)

borkdude11:01:49

glass half full or empty? ;)

Eugen11:01:58

I've notived reify and proxy are quite different IMO - since they work with classes and interfaces and introduce a lot of symbols. Are there building blocks in clj-kondo for dealing with that?

Eugen11:01:15

or we need something new to support those?

borkdude11:01:09

Most of the code supporting those things is in clj_kondo/impl/analyzer.clj

borkdude11:01:24

see the giant case statement in analyze-call and follow from there

Eugen11:01:25

thanks, I'll probably take a look this week. btw, cool stuff with nbb. I did a bit of work on https://github.com/titonbarua/shadow-cljs-gjs-target . Maybe I will have some time to continue and have something similar for Gnome desktop - uses gjs

borkdude11:01:22

Oh, that's cool :) There is #nbb but also #obb which is for macOS JXA which I believe is similar to the Gnome stuff, maybe

borkdude11:01:35

so maybe we can have #gbb soon ;)

Eugen11:01:54

thanks, yeah I was thinking about obb - but naming colided in my head

👍 1
Eugen11:01:47

maybe gbb (gnome babashka )?

borkdude11:01:16

yes, that's what I said above :)

Eugen11:01:34

I missed that - I was typing 🙂

borkdude11:01:11

multitasking is hard. now that I have windows + WSL2 + wslg I can easily try this gjs stuff out I think

borkdude11:01:03

what's the status of gnome? isn't it a bit old/deprecated in favor of other stuff in the coming years? or it's not going away soon?

borkdude11:01:27

anyway, feel free to experiment with obb -> gbb and perhaps it can join the babashka org if you think it's a useful thing :)

Eugen11:01:16

no, it's here to stay. Ubuntu moved back to shipping with Gnome after they tried Unity

borkdude11:01:46

I heard gnome plugins are quite notorious in that they are single threaded and can crash gnome?

Eugen11:01:51

Wayland is getting some traction to replace ancient http://X.org

Eugen11:01:19

yes, not the best situation - happened to me quite a few times.

Eugen11:01:45

Gnome 40 came out last year and they promissed they are taking more care of plugin compatibility and stability

borkdude11:01:22

perhaps https://www.npmjs.com/package/node-gtk can also be used with #nbb already, or something else on node

Eugen11:01:14

yeah, I'll see if I have some time to look at those as well

borkdude11:01:29

ok, but it's good to hear gnome is not going anyway, then gbb might be a good idea :)

👍 1
Eugen11:01:42

but right now I'm happy I managed to implement Calcite over XML

🎉 1
borkdude16:01:21

Quick follow-up bugfix release to the previous one: clj-kondo 2022.01.15 • Fix https://github.com/clj-kondo/clj-kondo/issues/1537: stackoverflow with potemkin import vars with cyclic references • Fix https://github.com/clj-kondo/clj-kondo/issues/1545: `recur` in `cond->` gives warning about `recur` not in tail position. • Fix https://github.com/clj-kondo/clj-kondo/issues/1535: support CLJS vars / protocols references via dot rather than slash.