Fork me on GitHub
#clj-kondo
<
2020-06-19
>
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: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

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

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)

delaguardo20:06:49

:hugging_face: