clj-kondo

https://github.com/clj-kondo/clj-kondo
borkdude 2020-09-13T09:09:35.155600Z

Does anyone using flycheck-clj-kondo want to take a look at this PR? https://github.com/borkdude/flycheck-clj-kondo/pull/10

2020-09-13T09:11:36.156300Z

i don't use cider, but the actual code doesn't look like it is tied to cider. does that seem right?

borkdude 2020-09-13T09:13:08.156500Z

that's right

2020-09-13T09:13:24.156700Z

ok, i'll take a look then

borkdude 2020-09-13T09:15:09.156900Z

thanks!

2020-09-13T10:11:39.161700Z

@borkdude ok, i've looked and tested a bit. i'd like to confirm that i understand the background of the situation. iiuc, in its current state, when one sends .cljc content to clj-kondo via stdin, using --lang clj or --lang cljs is likely to fail if there are any reader conditionals. does that sound right? so when using cider, there can be two repl connections, one to a clj repl and another to a cljs repl. i guess based on the current major-mode, which repl is used for evaluation is determined. so flycheck-clj-kondo also looks at the major mode to decide what value to use as the value for --lang. but this is a problem for .cljc content because if one is switched to either clojure-mode or clojurescript-mode, --lang will end up being passed clj or cljs, basically making it likely that clj-kondo cannot cope, getting something typically like this:

<stdin>:0:0: error: Can't parse <stdin>, Unparsable namespace form

borkdude 2020-09-13T10:12:12.161900Z

true

2020-09-13T10:12:21.162200Z

ok, so i think this pr tries to cope with this.

2020-09-13T10:12:54.162700Z

it provides a buffer local variable that overrides things -- one can set it to "cljc".

borkdude 2020-09-13T10:14:07.163100Z

That's right. I wondered about the use of eval, if this was legitimate there

2020-09-13T10:14:22.163300Z

he he -- i am not so sure either.

2020-09-13T10:14:39.163700Z

there is some other refactoring too which i wondered whether was necessary.

2020-09-13T10:33:03.167Z

@borkdude so i tried modifying the code a bit -- pulling the command construction back out into a let like before and not using eval. you might have guessed this, but that doesn't seem to work. may be it is because the value of flycheck-clj-kondo-lint-lang is then captured at macro compile time and consequently what one sets it to later is not reflected when constructing the command line to execute. does that sound plausible?

borkdude 2020-09-13T10:34:07.167200Z

yes.

borkdude 2020-09-13T10:35:47.167800Z

maybe the macros can all be turned into functions?

👍 1
2020-09-13T10:36:13.168Z

i can investigate that

2020-09-13T10:51:41.169500Z

fwiw, it appears that using eval within the context of :command is a thing: https://github.com/flycheck/flycheck/issues/1515 this issue had to do with extending that to work for the first part of :command -- the one place it didn't (doesn't) work. which is not our case.

2020-09-13T11:06:17.174400Z

@borkdude i'm not sure i quite follow about turning macros into functions. i did find that there is a function alternative (https://github.com/flycheck/flycheck/blob/master/flycheck.el#L5681) to the macro flycheck-define-checker, but i'm not sure how using that would help here. however, as far as constructing the command is concerned, there might be an alternative to using eval. i found a list here of the kinds of things one can use when constructing an arg for the command: https://github.com/flycheck/flycheck/blob/master/flycheck.el#L5899 (eval FORM) is one of the listed options, but there are also things like: https://github.com/flycheck/flycheck/blob/master/flycheck.el#L6002-L6004

borkdude 2020-09-13T11:08:01.174800Z

ooh option-flag might be what we want here

2020-09-13T11:08:15.175100Z

am looking for example usages

2020-09-13T11:20:37.177800Z

go http://grep.app

2020-09-13T11:21:05.178300Z

will give it an attempt now

borkdude 2020-09-13T11:21:06.178400Z

can we accomplish the desired behavior with that?

2020-09-13T11:24:51.179400Z

@borkdude hmm, i think we want to fall back to lang if there is no value defined for flycheck-clj-kondo-lint-lang. i am not sure if option-flag will be enough.

borkdude 2020-09-13T11:25:52.180200Z

option-flag takes not a default?

2020-09-13T11:26:39.180800Z

it doesn't look like it to me. may be i misunderstood?

2020-09-13T11:27:11.181Z

fwiw, when searching for uses of option-flag i did find that it wasn't uncommon for flycheck things to be using eval.

borkdude 2020-09-13T11:27:40.181600Z

ok, maybe it's alright then

2020-09-13T11:28:05.181900Z

so we have done due diligence at least 🙂

borkdude 2020-09-13T11:29:11.182100Z

yes, thanks for the review!

2020-09-13T11:29:23.182400Z

np!

borkdude 2020-09-13T11:30:39.183Z

Maybe a bit bikesheddy, but maybe flycheck-clj-kondo-lang is a better name than flycheck-clj-kondo-lint-lang

2020-09-13T11:31:08.183300Z

i did think the lint-lang version was a bit on the long side

2020-09-13T11:32:06.183500Z

otoh this is emacs lisp 😛

borkdude 2020-09-13T11:32:30.183700Z

I left a comment.

borkdude 2020-09-13T11:32:51.184100Z

it's emacs lisp, but also kondo which emphasizes cleaning up things you don't need ;)

2020-09-13T11:33:09.184400Z

ha ha ha -- good point