Fork me on GitHub
#clj-kondo
<
2020-06-19
>
borkdude08:06:01

maybe @delaguardo ^?

delaguardo08:06:22

I already reserve few hours this weekend for that)

borkdude08:06:54

๐Ÿ˜„ โค๏ธ

borkdude10:06:27

This is an example of rewriting a slingshot/try+ call to something clj-kondo understands using the new "hooks" functionality: https://github.com/borkdude/clj-kondo/blob/macros-sci/corpus/.clj-kondo/macroexpand/try_plus.clj

borkdude10:06:38

(cc @martinklepsch)

borkdude10:06:47

it's not the easiest macro example, but it shows that it's possible to do it. this is an easier one which is syntactically isomorphic to the jdbc with-transaction macro: https://github.com/borkdude/clj-kondo/blob/macros-sci/corpus/.clj-kondo/macroexpand/weird_macro.clj

borkdude14:06:21

@martinklepsch so this is a newer version of a hook that can teach clj-kondo about rum defc: https://github.com/borkdude/clj-kondo/blob/81e3e8a66beaf07c011546ff89b7d7358cd00644/corpus/macroexpand.clj#L74-L111

martinklepsch15:06:04

downloaded this binary and added the config to the ns form of a file but it seems to behave as before

martinklepsch15:06:17

Iโ€™m pretty sure the right clj-kondo binary is used

martinklepsch15:06:28

clj-kondo v2020.06.13-SNAPSHOT

borkdude15:06:36

can you give me that same file?

borkdude15:06:48

works for me

borkdude15:06:04

can you try running clj-kondo --lint rum.clj?

borkdude15:06:31

it should output:

$ clj-kondo --lint /tmp/rum.clj
/tmp/rum.clj:35:1: error: quux/with-mixin is called with 4 args but expects 1
/tmp/rum.clj:35:13: error: unresolved symbol a
/tmp/rum.clj:37:1: warning: redefined var #'quux/with-mixin

martinklepsch15:06:27

figured it out by trying to trim down my file

martinklepsch15:06:49

the :hooks key should use the fully qualified macro name

{:clj-kondo/config '{:hooks {rum.core/defc "

martinklepsch15:06:11

before the key was just rum/defc

martinklepsch15:06:47

but these macros live in rum.core

borkdude15:06:10

yeah sorry, that was just for my own tests ๐Ÿ™‚ I actually don't use rum so I didn't bother to look what the real ns name was ๐Ÿ™‚

martinklepsch15:06:08

very very cool though, seems to work great!

borkdude15:06:12

thanks for testing

martinklepsch15:06:53

my pleasure, very excited to get this into our CI ๐Ÿ™‚

borkdude15:06:00

so how many variations of this defc macro are there, only one?

borkdude15:06:09

rum/defcs I see, is that syntactically the same as defc?

borkdude15:06:20

if so, then adding a lint-as rule for this should work (it doesn't right now, but it can be made so)

martinklepsch17:06:40

thereโ€™s also defcc but I think itโ€™s also the same

martinklepsch17:06:49

they basically add extra arguments to the function

martinklepsch17:06:02

so as long as the argvec is parsed correctly this should be fine

borkdude17:06:50

ok then lint-as can also be used for that one, nice

robert-stuttaford20:06:46

YAAAAAAAAAAAAY -dance-

borkdude14:06:47

Note, the string in the config is only for demo, it may also be a filepath relative to the .clj-kondo directory

borkdude14:06:49

I might still rename the naming of {:hooks {rum/defc ...}} since this gets invoked during analysis of a call only. so maybe {:hooks {:analyze-call {rum/defc ...}}} might be better for future extension

borkdude14:06:19

and then we could potentially add more and more hooks

borkdude14:06:22

but that's a minor detail.

borkdude20:06:35

@delaguardo Seems someone worked on including clj-kondo into super-linter: https://github.com/github/super-linter/pull/197

delaguardo20:06:40

That's even better) now I have free two hours on weekend)