Clj-kondo and `defmulti`

I have some multi-methods defined that take several parameters, only a part of which are used by the dispatch function.

I have a definition like the following:

(defmulti foobar
  "Takes a `foo` and a `bar`, and combines them using `baz` and `quuz`"
  (fn[foo bar baz quuz]
    (,,, (do-some-stuff foo bar))))

I’m getting a warning about unused bindings for baz and quuz, but since the documentation of multimethods goes in the defmulti, it is handy to have the parameters’ names there, rather than just underscores.

Screenshot-2021-03-02T20:28:17+02:00

Is there any configuration option for clj-kondo to ignore this type of instance?

You can start the names with underscores: _baz and _quux, or use a #_:clj-kondo/ignore annotation.

Thanks, Michiel!

Another workaround, which involves no “noise” other than the healthy hum of Clojure metadata, is to declare multimethod arglists explicitly:

(defmulti fig 
  {:arglists '([a b c])}
  (fn [a _ _]
    a))

This technique quells the warning, in Calva at least. And it enables clojure.repl/doc (and presumably those nice HTML documentation generators) to see the arglist.

3 Likes