borkdude / flycheck-clj-kondo

Emacs integration for clj-kondo via flycheck
94 stars 17 forks source link

basic cljs test broken with new namespace error #19

Open ikappaki opened 2 years ago

ikappaki commented 2 years ago

Hi,

it appears one of the recent clj-kondo releases have broken the cljs basic tests, whereby a new namespace error is being thrown:

Namespace name does not match file name: cond-without-else1

To reproduce:

  1. install clj-kondo v2022.04.25
  2. install https://github.com/doublep/eldev
  3. run eldev test from within the source directory
  4. The flycheck-define-checker/clj-kondo-cljs/basic test fails with an additional error at line3 column:5:
    Test flycheck-define-checker/clj-kondo-cljs/basic condition:
    (ert-test-failed
     ((should
       (equal
    (mapcar ... expected)
    (mapcar ... flycheck-current-errors)))
      :form
      (equal
       (#s(flycheck-error #<killed buffer> clj-kondo-cljs "d:/src/flycheck-clj-kondo/test/corpus/basic.cljs" 11 3 "use :else as the catch-all test expression in cond" warning nil nil ...)
      #s(flycheck-error #<killed buffer> clj-kondo-cljs "d:/src/flycheck-clj-kondo/test/corpus/basic.cljs" 18 3 "use :else as the catch-all test expression in cond" warning nil nil ...))
       (#s(flycheck-error #<killed buffer> clj-kondo-cljs "d:/src/flycheck-clj-kondo/test/corpus/basic.cljs" 3 5 "Namespace name does not match file name: cond-without-else1" error nil nil ...)
      #s(flycheck-error #<killed buffer> clj-kondo-cljs "d:/src/flycheck-clj-kondo/test/corpus/basic.cljs" 11 3 "use :else as the catch-all test expression in cond" warning nil nil ...)
      #s(flycheck-error #<killed buffer> clj-kondo-cljs "d:/src/flycheck-clj-kondo/test/corpus/basic.cljs" 18 3 "use :else as the catch-all test expression in cond" warning nil nil ...)))
      :value nil :explanation
      (proper-lists-of-different-length 2 3
                    (#s(flycheck-error #<killed buffer> clj-kondo-cljs "d:/src/flycheck-clj-kondo/test/corpus/basic.cljs" 11 3 "use :else as the catch-all test expression in cond" warning nil nil ...)
                       #s(flycheck-error #<killed buffer> clj-kondo-cljs "d:/src/flycheck-clj-kondo/test/corpus/basic.cljs" 18 3 "use :else as the catch-all test expression in cond" warning nil nil ...))
                    (#s(flycheck-error #<killed buffer> clj-kondo-cljs "d:/src/flycheck-clj-kondo/test/corpus/basic.cljs" 3 5 "Namespace name does not match file name: cond-without-else1" error nil nil ...)
                       #s(flycheck-error #<killed buffer> clj-kondo-cljs "d:/src/flycheck-clj-kondo/test/corpus/basic.cljs" 11 3 "use :else as the catch-all test expression in cond" warning nil nil ...)
                       #s(flycheck-error #<killed buffer> clj-kondo-cljs "d:/src/flycheck-clj-kondo/test/corpus/basic.cljs" 18 3 "use :else as the catch-all test expression in cond" warning nil nil ...))
                    first-mismatch-at 0)))
    FAILED  5/6  flycheck-define-checker/clj-kondo-cljs/basic (0.179791 sec)

It appears that clj-kondo now (rightly) errors namespaces that do not correspond to the right filesystem path, and thus either requires the test to be split into two files or add the new error into the test's error list?

https://github.com/borkdude/flycheck-clj-kondo/blob/35daaccc75b0367844b249a8cb05bf73bcebd52a/test/corpus/basic.cljs#L1

(ns test.corpus.basic)

(ns cond-without-else1
  (:refer-clojure :exclude [cond])
  (:require [clojure.core :as c]))

(def n (rand-int 10))

(c/cond
  (neg? n) "negative"
  :default "positive")

(ns cond-without-else2)
(def n (rand-int 10))

(cond
  (neg? n) "negative"
  :default "positive")

;; this one should not be caught:
(cond
  (odd? n) 1
  :else 2)

Thanks

borkdude commented 2 years ago

Either solution is fine by me!