Fork me on GitHub
#clj-kondo
<
2020-05-24
>
juan.ignacio84815:05:45

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?

borkdude15:05:43

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

juan.ignacio84815:05:18

(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]))

borkdude15:05:07

@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))))

juan.ignacio84815:05:39

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

borkdude15:05:19

what version of clj-kondo are you using?

juan.ignacio84815:05:32

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

borkdude15:05:47

just upgrade, then try again

juan.ignacio84815:05:00

It's probably that 🙂 I'll try

borkdude15:05:03

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

borkdude15:05:26

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

juan.ignacio84815:05:00

[[email protected] 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

juan.ignacio84815:05:51

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

juan.ignacio84815:05:47

however there's also another arity for defspec

juan.ignacio84815:05:21

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

borkdude15:05:43

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))))

borkdude15:05:39

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 😉

juan.ignacio84815:05:35

Yes, it works 😄