clj-kondo

https://github.com/clj-kondo/clj-kondo
nmkip 2020-05-24T15:12:45.244600Z

I'm getting an error that says unresolved symbol merge identity In my .clj-kondo/config.edn I added this:

{:lint-as {clojure.test.check.properties/for-all clojure.core/let
           clojure.test.check.clojure-test/defspec clj-kondo.lint-as/def-catch-all}}
Am I missing something?

borkdude 2020-05-24T15:13:43.245300Z

can you also provide the namespace form? this way I can verify if you made the right config

nmkip 2020-05-24T15:14:18.245400Z

(ns properties-playground.test-check.merge-test
  (:require [clojure.test :refer :all]
            [clojure.test.check.clojure-test :refer [defspec]]
            [clojure.test.check.properties :as prop]
            [clojure.test.check.generators :as gen]))

borkdude 2020-05-24T15:17:07.246200Z

@juan.ignacio848 This does not give any unresolved symbols for me:

(ns properties-playground.test-check.merge-test
  {:clj-kondo/config '{:lint-as {clojure.test.check.clojure-test/defspec clj-kondo.lint-as/def-catch-all}}}
  (:require [clojure.test :refer :all]
            [clojure.test.check.clojure-test :refer [defspec]]
            [clojure.test.check.properties :as prop]
            [clojure.test.check.generators :as gen]))

(defspec merge-identity
  (prop/for-all [m1 (gen/map gen/keyword gen/small-integer)]
                (= m1
                   (merge m1 {})
                   (merge {} m1))))

nmkip 2020-05-24T15:18:39.247100Z

The map you added in the namespace form is equivalent to having the config.edn?

borkdude 2020-05-24T15:18:49.247300Z

yes

borkdude 2020-05-24T15:19:19.248200Z

what version of clj-kondo are you using?

nmkip 2020-05-24T15:19:32.248500Z

def-catch-all is something new? I don't remember when was the last time I updated clj-kondo 🙂

borkdude 2020-05-24T15:19:47.248700Z

just upgrade, then try again

nmkip 2020-05-24T15:20:06.249100Z

v2019.11.23

nmkip 2020-05-24T15:21:00.249500Z

It's probably that 🙂 I'll try

nmkip 2020-05-24T15:22:05.249800Z

https://github.com/borkdude/clj-kondo/releases/tag/v2020.01.10 --> def-catch-all

borkdude 2020-05-24T15:23:03.250200Z

btw you can also try clojure.core/def for better linting. the catch-all is a last resort really

borkdude 2020-05-24T15:23:26.250600Z

prop/for-all can be linted like let like you already had

nmkip 2020-05-24T15:24:00.250800Z

[nmkip@nmkip-pc test_check]$ clj-kondo --lint merge_test.clj 
merge_test.clj:2:34: warning: use alias or :refer
linting took 20ms, errors: 0, warnings: 1

nmkip 2020-05-24T15:24:51.251700Z

Ohh, my auto-completion didn't recommended me clojure.core/def, it was my first attempt though

nmkip 2020-05-24T15:25:47.252300Z

however there's also another arity for defspec

nmkip 2020-05-24T15:26:21.252900Z

which I'm not using so I will change it to clojure.core/def

borkdude 2020-05-24T15:26:43.253200Z

it does seem to work:

(ns properties-playground.test-check.merge-test
  {:clj-kondo/config '{:lint-as {clojure.test.check.clojure-test/defspec clojure.core/def
                                 clojure.test.check.properties/for-all clojure.core/let}}}
  (:require [clojure.test :refer :all]
            [clojure.test.check.clojure-test :refer [defspec]]
            [clojure.test.check.properties :as prop]
            [clojure.test.check.generators :as gen]))

(defspec merge-identity 100
  (prop/for-all [m1 (gen/map gen/keyword gen/small-integer)]
                (= m1
                   (merge m1 {})
                   (merge {} m1))))

borkdude 2020-05-24T15:27:39.253900Z

This is probably a lack of clojure.core/def syntax checking that works out nice for this use case. Might break in the future if syntax checking improves 😉

nmkip 2020-05-24T15:28:35.254300Z

Yes, it works 😄

nmkip 2020-05-24T15:29:05.254800Z

Thanks!