Fork me on GitHub
#clj-kondo
<
2020-05-06
>
fiddlerwoaroof00:05:34

Is there an exclusion list for unused imports?

fiddlerwoaroof00:05:33

Also, was there a way to use Clojure metadata to configure clj-kondo?

seancorfield01:05:10

@fiddlerwoaroof You can provide metadata on the ns form for per-file configuration overrides.

seancorfield01:05:37

(ns worldsingles.expectations.mobile.user
  {:clj-kondo/config
   '{:lint-as
     {worldsingles.expectations.mobile.user/patch-notifications
      clj-kondo.lint-as/def-catch-all}}}
  (:require [clj-time.coerce :as tc]
            [clj-time.core :as t]
            [clj-time.format :as tf]
...

seancorfield01:05:55

Note the ' so the symbol names do not get evaluated!

fiddlerwoaroof01:05:04

Thanks, I really dislike the friction a separate config file adds

seancorfield01:05:36

(metadata on ns can come before the namespace name if you use ^)

seancorfield01:05:14

I have a config file in each project, at this point, with just that one override so far.

fiddlerwoaroof01:05:16

My current issue is that I have to import a JDBC driver, but I never use it directly and I can't figure out how to hide the warning

seancorfield01:05:34

Really? Why is that?

fiddlerwoaroof01:05:55

Because it's used implicitly when the connection string is parsed

fiddlerwoaroof01:05:03

Hmm, maybe I don't need the import

seancorfield01:05:06

Neither clojure.java.jdbc nor next.jdbc need you to import the JDBC drivers.

fiddlerwoaroof01:05:38

Cool, I wasn't thinking things through

seancorfield01:05:51

Fixed your warning for you! 😆

lread20:05:53

Heya @borkdude! I am slowly dipping my toes back into rewrite-cljc. It has been a long while since I spent time with my old reliable and helpful clj-kondo. I have missed her and the reunion is delightful. I noticed 2 small things while updating to the latest clj-kondo (remember I have been away for literally months!): 1. clj-kondo --help does not show cljc as a valid option for --lang, should it? 2. I had to add "<stdin>" to my clj-kondo .config.edn->`:output` -> :include-files to get spacemacs to show clj-kondos findings. I now have :output {:include-files ["<stdin>" "^src" "^test" "^script"]}. If having to include <stdin> is by design, a note in the docs might be helpful. Am happy to make PRs for above if there is any work to do.

borkdude20:05:24

@lee 1) Yeah, it should. 2) Why are you excluding test files from linting in your editor? Clj-kondo is pretty helpful there too. Scripts: dunno. Maybe just try without the entire include-files thing and start over?

lread20:05:43

For 2) I have a single clj-kondo config to support CI scripts and my editor. My CI script runs clj-kondo with my project classpath but I only want to see clj-kondo warnings from my project sources. You helped me come up with this solution in the very early days, but that was long ago and maybe there is a better way.

borkdude20:05:33

@lee In CI you can add the --config flag to pass additional config, they will be merged

lread20:05:59

ah… ok, thanks will give that a go.

lread21:05:04

ya that works great, thanks @borkdude! simple_smile

yonatanel20:05:21

Hi, I’ve made a try-let abomination macro that needs to be linted as both a let and a try block. How can I configure it? Usage:

(try-let [a (db-connection)
          b (might-throw)]
  (process a b)
  (catch Exception e
    (when a (close a))
    (when b (close b))
    (throw e)))

borkdude21:05:22

you can turn off linting with :unresolved-symbol {:exclude [(weird.macros/try-let)]}

yonatanel21:05:03

Is it possible to extend the analyzer instead with a custom analyzer? I scanned the source briefly and I can’t find a way?

borkdude21:05:40

not at the moment

seancorfield22:05:40

@yonatanel It won't help you but my opinion, after spending a bunch of time trying to get clj-kondo to "like" some of my macro-based code, is that it's a really good idea to make sure you don't create new syntax via macros that doesn't "match" something that is in Clojure already 🙂 It's made it clear to me just how hard it would be for someone new to my code to be able to read stuff that uses macros that have "unexpected" syntax. I'm seriously rethinking some of the syntax in my Expectations library at this point, after wrestling with clj-kondo!

❤️ 24
yonatanel22:05:31

True, we get carried away sometimes.

practicalli-johnny09:05:09

First rule of macro club, don't create macro's (unless there is an extremely compelling reason)