clojure-emacs / squiggly-clojure

Flycheck checker for Clojure, using eastwood and core.typed.
GNU General Public License v3.0
204 stars 25 forks source link

Warnings of eastwood are not shown #34

Closed SeriousBug closed 8 years ago

SeriousBug commented 8 years ago

Hello, I'm having problem using squiggly-clojure with boot. While the warnings from core.typed and kibit are displayed, warnings from eastwood are not shown.

My ~/.boot/profile.boot file:

(require 'boot.repl)

(swap! boot.repl/*default-dependencies* conj
       '[cider/cider-nrepl "0.11.0-SNAPSHOT"]
       '[acyclic/squiggly-clojure "0.1.4"])

(swap! boot.repl/*default-middleware* conj
       'cider.nrepl/cider-middleware)

Relevant portion of init.el:

(require 'flycheck)
(require 'flycheck-pos-tip)
(require 'flycheck-clojure)
(eval-after-load 'flycheck '(flycheck-clojure-setup))
(add-hook 'after-init-hook #'global-flycheck-mode)
(eval-after-load 'flycheck
  '(setq flycheck-display-errors-function #'flycheck-pos-tip-error-messages))

To reproduce the problem, I first cloned this repository, and made the following change, adding the boot files and adding some code to trigger the checkers.

diff --git a/sample-project/boot.properties b/sample-project/boot.properties
new file mode 100644
index 0000000..2f202a2
--- /dev/null
+++ b/sample-project/boot.properties
@@ -0,0 +1,3 @@
+BOOT_CLOJURE_VERSION=1.7.0
+BOOT_VERSION=2.5.2
+BOOT_EMIT_TARGET=no
diff --git a/sample-project/build.boot b/sample-project/build.boot
new file mode 100644
index 0000000..2e41e98
--- /dev/null
+++ b/sample-project/build.boot
@@ -0,0 +1,13 @@
+(set-env!
+  :source-paths #{"src"}
+  :resource-paths #{"src"}
+  :dependencies '[[org.clojure/clojure    "1.7.0"]
+                  [boot/core              "2.3.0"      :scope "test"]])
+
+
+(task-options!
+ pom {:project 'sample-project'
+       :version "0.1.0-SNAPSHOT"
+       :description "FIXME: write description"
+       :license {"EPL" "http://www.eclipse.org/legal/epl-v10.html"}}
+  target {:dir #{"target"}})
diff --git a/sample-project/src/sample_project/boring.clj b/sample-project/src/sample_project/boring.clj
index 94fef7e..0b3981f 100644
--- a/sample-project/src/sample_project/boring.clj
+++ b/sample-project/src/sample_project/boring.clj
@@ -19,3 +19,11 @@
 ;; Local Variables:
 ;; flycheck-disabled-checkers: ()
 ;; End:
+
+(defn fly-tests []
+  true)
+
+(def foo (+ 1 2))
+
+(defn bar []
+  (assoc "..." :key "..."))

Afterwards, I run boot repl in the sample_project directory, open boring.clj with Emacs, and use cider-connect to connect to the nrepl that was started by boot. Finally, I use cider-load-buffer, then make a change in the file and save to start the flycheck.

At this point, kibit warns about (+ 1 2) and core.typed warns about assoc. However, eastwood does not warn about fly-tests being redefined. Looking into nrepl-messages buffer shows that eastwood does actually detect the problem. Relevant part of the nrepl-messages:

(---> 
  op  "eval"
  session  "b56946c6-2b55-4382-9e57-425b74bd608c"
  code  "(do (require 'squiggly-clojure.core) (squiggly-clojure.core/check-ew 'sample-project.boring))"
  id  "15"
)
(<- 
  id  "14"
  session  "b56946c6-2b55-4382-9e57-425b74bd608c"
  status  ("done")
)
(<- 
  changed-namespaces  (dict)
  id  "14"
  repl-type  "clj"
  session  "b56946c6-2b55-4382-9e57-425b74bd608c"
  status  ("state")
)
(<- 
  id  "15"
  out  "({:line 23, :column 7, :msg Var fly-tests def'd 2 times at line:col locations: sample_project/boring.clj:9:7 sample_project/boring.clj:23:7, :file file:/home/kaan/.boot/cache/tmp/tmp/test/squiggly-clojure/sample-project/k69/-grrwi1/sample_project/boring.clj, :level :warning})\n"
  session  "b56946c6-2b55-4382-9e57-425b74bd608c"
)
(<- 
  id  "15"
  ns  "boot.user"
  session  "b56946c6-2b55-4382-9e57-425b74bd608c"
  value  "\"[{\\\"line\\\":23,\\\"column\\\":7,\\\"msg\\\":\\\"Var fly-tests def'd 2 times at line:col locations: sample_project\\\\/boring.clj:9:7 sample_project\\\\/boring.clj:23:7\\\",\\\"file\\\":\\\"file:\\\\/home\\\\/kaan\\\\/.boot\\\\/cache\\\\/tmp\\\\/tmp\\\\/test\\\\/squiggly-clojure\\\\/sample-project\\\\/k69\\\\/-grrwi1\\\\/sample_project\\\\/boring.clj\\\",\\\"level\\\":\\\"warning\\\"}]\""
)

This problem doesn't happen if I use lein.

SeriousBug commented 8 years ago

Ah, I think I found the problem. I think it is caused by boot using some different directory to cache the files. In the warning message, the file path shows as :file file:/home/kaan/.boot/cache/tmp/tmp/test/squiggly-clojure/sample-project/k69/-grrwi1/sample_project/boring.clj. But the actual file that is open in my editor isn't that file.

samestep commented 8 years ago

Why was this closed? The issue has not been fixed; no Eastwood warnings are shown when using Boot.

pnf commented 8 years ago

It was closed, because OP said he found the problem. However, I don't use boot and will probably not be learning it soon. You're welcome to submit a PR.