Fork me on GitHub
#clj-kondo
<
2019-07-10
>
fiddlerwoaroof00:07:24

It'd be interesting if clj-kondo could interpret metadata declarations and use them to control linting

lread02:07:02

I am running both joker and clj-kondo in spacemacs. There certainly is overlap between the two tools, and I am thinking of dropping joker. Do you think I will regret dropping joker?

borkdude06:07:30

@fiddlerwoaroof do you have an example?

fiddlerwoaroof16:07:12

If I have something like this:

(defn fun {:ignore-vars '[arg1 arg2]} 
  [arg1 arg2])
clj-kondo could supress warnings about arg1 and arg2 being unused.

borkdude06:07:23

@lee I use a small wrapper script that turns off some joker features and I use that together with clj-kondo. I could share it if you want

borkdude11:07:35

@lee:

#!/usr/bin/env bash

## turn off some joker features, so I can test clj-kondo better

/usr/local/bin/joker "$@" 2>&1 \
    | grep -v "unused" \
    | grep -v "unsupported binding form" \
    | grep -iv "unable to resolve symbol" \
    | sed -e 's/$/ (joker)/'
exit 0

borkdude11:07:05

I've put that in ~/Dropbox/bin and put that on the path before /usr/local/bin

borkdude11:07:43

in emacs I use both clj-kondo and joker with flycheck

borkdude11:07:55

maybe I should put this in a blog 😉

lread11:07:48

thanks! it might go well as a side-note in your docs where you talk about joker: https://github.com/borkdude/clj-kondo/blob/master/doc/editor-integration.md

borkdude11:07:53

well, it's kind of subjective what you want to suppress from joker, so it's not general advice, just how I happen to use it

borkdude11:07:10

btw, do you use emacs or some other editor?

borkdude11:07:02

@lee I'm fixing the quote-unquote bug right now. It results in a few less false positive while linting CLJS. e.g. here: https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/spec/alpha.cljc#L179 nice!

lread11:07:04

I am using spacemacs

lread11:07:44

So maybe a blog post is better then. Personally I am only interested in heating from joker when it sees something that clj-kondo cannot see.

borkdude11:07:15

With joker you might also be able to use its config to turn some things off, but I found a wrapper script to be more flexible

borkdude11:07:41

and if I really want vanilla joker, I do: /usr/local/bin/joker

lread11:07:32

thanks, I shall try it shortly!

lread11:07:23

yes your spacemacs docs (with joker) are what my current setup is based on

lread11:07:37

I think I prefer the wrapper script as well

borkdude11:07:59

maybe you could blog about it then 😉

lread12:07:04

maybe I should setup a blog someday!

lread12:07:21

so, that blog, if someone were to write it, might highlight what joker brings in addition to clj-kondo. As a newb, I’m currently unclear on that.

borkdude12:07:12

I think the most notable difference today is that joker is able to do some basic type checking on literals like (inc "string")

borkdude12:07:23

but I want to get that in clj-kondo as well

borkdude12:07:55

I'd say just use them both and turn off the overlapping parts with a script

lread12:07:56

so if you add that feature first, maybe the blog post advice on joker would change.

borkdude12:07:20

might want to hold off a bit then

lread13:07:47

just tried quote-unquote fix, works great, thanks!

lread13:07:32

also joker is now much quieter thanks to your wrapper script. :thumbsup:

lread13:07:42

@borkdude, cljs compiler has a :fn-deprecated warning. I fail my build if I use anything deprecated - except when I am calling my own deprecated fn from a deprecated function or am testing my own deprecated fns. My build is currently awkward/brittle when handling these exceptions. Do you have plans to add deprecated checking to clj-kondo?

borkdude15:07:21

@lee sure! can you post an issue with some examples? would be happy to support it

lread15:07:39

cool! I think the clj only folks will probably find it useful too. I’ll try to get a git issue up today.

fiddlerwoaroof16:07:12

If I have something like this:

(defn fun {:ignore-vars '[arg1 arg2]} 
  [arg1 arg2])
clj-kondo could supress warnings about arg1 and arg2 being unused.

borkdude16:07:11

@fiddlerwoaroof the way to solve that right now is to start the argument names with an underscore: (fn [_arg1 _arg2])

fiddlerwoaroof16:07:49

@borkdude cool, the other use I thought of was for describing the syntax of custom macros.

fiddlerwoaroof16:07:40

One thought would be something like this:

(defmacro deftest
  {:clj-kondo/binds-globally '[test-name]}
  [test-name & cases])

fiddlerwoaroof16:07:58

Then, when the macro is used, clj-kondo could add the value of test-name to its dictionary of available names. I understand a lot of this can be done in the config file but I'd rather have the option to declare this stuff inline.

borkdude17:07:26

That is a little bit complicated, since clj-kondo might lint files where your deftest macro is used, but it doesn't yet know about the macro itself. E.g. when using editor integration, you only lint one file at a time

fiddlerwoaroof17:07:57

Sure, but there's already something like that with the --cache options?

fiddlerwoaroof17:07:13

e.g., IIUC, arity errors don't work correctly without a cache

borkdude17:07:05

clj-kondo can function correctly without a cache, but will just underreport arity errors when it doesn't know the arity of a called function with your example clj-kondo will overreport without a cache, something which I think is undesirable and hard to debug when users will report those false positives

borkdude17:07:27

in general, it's best to err on the side of false negatives

borkdude17:07:47

also, so far my impression is that most users don't like tool-specific annotations inside their code. I have considered it at one point for e.g. https://github.com/borkdude/clj-kondo/issues/241, but when a solution arose that required no changes to the code, that was the preferred option

borkdude17:07:44

I'm not completely dismissing the idea and I've also experimented with a namespace local config for some linters

borkdude18:07:34

but so far doing it via the config file is the preferred and most simple way

borkdude18:07:45

for testing, I sometimes use this:

(ns ^{:clj-kondo/config '{:lint-as {foo/foo clojure.core/def}}} foo)
(defmacro foo [_name & _body] ,,,)
(foo x)
(x 1)
it works, but it's undocumented

lread18:07:42

hey there @borkdude, I submitted the my first clj-kondo feature request https://github.com/borkdude/clj-kondo/issues/338

lread20:07:36

Now linting my project on circleci with clj-kondo! Fun stuff!

bananadance 12