weavejester/cljfmt

Exception when using 0.10.x series as a Leiningen plugin

axvr opened this issue ยท 3 comments

axvr commented

Hi, when I try to use the 0.10.x versions of the Leiningen plugin lein-cljfmt I'm getting the following exception:

java.lang.ClassCastException: class java.io.File cannot be cast to class java.lang.String (java.io.File and java.lang.String are in module java.base of loader 'bootstrap')
 at cljfmt.io$file_entity.invokeStatic (io.clj:35)
    cljfmt.io$file_entity.invoke (io.clj:33)
    cljfmt.tool$find_files.invokeStatic (tool.clj:24)
    cljfmt.tool$find_files.invoke (tool.clj:23)
    cljfmt.tool$recursively_find_files$fn__4701.invoke (tool.clj:137)
    clojure.core$map$fn__5935.invoke (core.clj:2772)
    clojure.lang.LazySeq.sval (LazySeq.java:42)
    clojure.lang.LazySeq.seq (LazySeq.java:51)
    clojure.lang.RT.seq (RT.java:535)
    clojure.core$seq__5467.invokeStatic (core.clj:139)
    clojure.core$apply.invokeStatic (core.clj:662)
    clojure.core$mapcat.invokeStatic (core.clj:2800)
    clojure.core$mapcat.doInvoke (core.clj:2800)
    clojure.lang.RestFn.invoke (RestFn.java:423)
    cljfmt.tool$recursively_find_files.invokeStatic (tool.clj:137)
    cljfmt.tool$recursively_find_files.invoke (tool.clj:136)
    cljfmt.tool$fix_no_config.invokeStatic (tool.clj:142)
    cljfmt.tool$fix_no_config.invoke (tool.clj:139)
    leiningen.cljfmt$execute_command.invokeStatic (cljfmt.clj:18)
    leiningen.cljfmt$execute_command.invoke (cljfmt.clj:15)
    leiningen.cljfmt$cljfmt.invokeStatic (cljfmt.clj:35)
    leiningen.cljfmt$cljfmt.doInvoke (cljfmt.clj:24)
    clojure.lang.RestFn.invoke (RestFn.java:425)
    clojure.lang.AFn.applyToHelper (AFn.java:156)
    clojure.lang.RestFn.applyTo (RestFn.java:132)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.core$apply.invokeStatic (core.clj:669)
    clojure.core$apply.invoke (core.clj:662)
    leiningen.core.main$partial_task$fn__7380.doInvoke (main.clj:284)
    clojure.lang.RestFn.applyTo (RestFn.java:139)
    clojure.lang.AFunction$1.doInvoke (AFunction.java:31)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.core$apply.invokeStatic (core.clj:669)
    clojure.core$apply.invoke (core.clj:662)
    leiningen.core.main$apply_task.invokeStatic (main.clj:334)
    leiningen.core.main$apply_task.invoke (main.clj:320)
    leiningen.core.main$resolve_and_apply.invokeStatic (main.clj:343)
    leiningen.core.main$resolve_and_apply.invoke (main.clj:336)
    leiningen.core.main$_main$fn__7469.invoke (main.clj:453)
    leiningen.core.main$_main.invokeStatic (main.clj:442)
    leiningen.core.main$_main.doInvoke (main.clj:439)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.core$apply.invokeStatic (core.clj:667)
    clojure.main$main_opt.invokeStatic (main.clj:514)
    clojure.main$main_opt.invoke (main.clj:510)
    clojure.main$main.invokeStatic (main.clj:664)
    clojure.main$main.doInvoke (main.clj:616)
    clojure.lang.RestFn.applyTo (RestFn.java:137)
    clojure.lang.Var.applyTo (Var.java:705)
    clojure.main.main (main.java:40)

I was able to reproduce this by creating the following files (and directories):

;;;; project.clj
(defproject com.example/tmp "0.1"
  :dependencies [[org.clojure/clojure "1.11.1"]]
  :plugins [[dev.weavejester/lein-cljfmt "0.10.4"]])
;;;; src/com/example/tmp.clj
(ns com.example.tmp)

Then running lein cljfmt check or lein cljfmt fix.

Thanks for the issue! I'll release 0.10.5 soon. I'll also add some smoke tests to the CI.

0.10.5 released, and I've added some smoke tests to prevent this from happening in future.

axvr commented

Excellent, I can confirm it works now. Thank you! ๐ŸŽ‰