cursive-ide / cursive

Cursive: The IDE for beautiful Clojure code
580 stars 7 forks source link

thrown? cannot be resolved #238

Open mtruyens opened 10 years ago

mtruyens commented 10 years ago

When using Clojure Test, the thrown? test is incorrectly flagged as "cannot be resolved"

Example

(deftest xyz (is (thrown? Exception (... exception raising code ... ))))

cursive-ide commented 10 years ago

Yes, I'm planning to fix this case. I need to add some indexing on multimethods (which is what is is using under the hood).

ikitommi commented 9 years ago

same for thrown-with-msg?.

marcomorain commented 8 years ago

:+1:

lenaschoenburg commented 8 years ago

Any update on this? Lots of unresolved symbols look somewhat ugly in the tests.

jnape commented 8 years ago

+1 @dignati Although to be fair, it's even worse than looking ugly in tests, because code analysis reports these "unresolved" symbols as warnings, which you will see regularly if you either manually kick off code analysis, or you commit via IntelliJ with the "Perform code analysis" checkbox; in this case, if any of the files you're committing include thrown? or thrown-with-msg? in their source, you'll get the warning popup, which can perhaps lead to ignoring warnings in your code due to regular false negatives.

marco-m commented 7 years ago

hello any news ?

madvas commented 6 years ago

yeah, would be great to see this resolved

ai212983 commented 6 years ago

3 years, bug is still here

brjann commented 5 years ago

Would be great to have this bug fixed.

dillonredding commented 5 years ago

5 years and still no fix. Is there any movement on this?

ai212983 commented 4 years ago

Abandon hope all ye who enter here

bluiska commented 4 years ago

Wow! I still have hope. It's 2020. Come on....

NPException commented 4 years ago

Any possible workaround for this in the meantime?

Lambeaux commented 4 years ago

Not a blocker; can still build & run tests but would be nice to see a fix.

jsyrjala commented 4 years ago

A related thing. First parameter to thrown? is also marked as cannot be resolved.

Here :import for ParameterNotFoundException is marked as unused, and it's usage in thrown? is marked as not resolved.

(ns foo.some-ns
  (:require [clojure.test :refer :all])
  (:import (com.amazonaws.services.simplesystemsmanagement.model ParameterNotFoundException)))

(deftest some-test
  (testing "foo"
    (is (thrown? ParameterNotFoundException
                 (do-something)))))
aneilbaboo commented 3 years ago

It looks like the issue is that thrown? is not a function or macro. It's merely a symbol that that is treated specially by the is macro. You can see the definition here. In other words, Cursive is reporting the symbol resolution failure the way it does for other macros that introduce new symbols.

The current solution is to disable symbol resolution for the offending macro using https://github.com/cursive-ide/cursive/issues/2417. The downside is that you lose all symbol resolution within an is expression.

A better solution will come with https://github.com/cursive-ide/cursive/issues/147.

raymcdermott commented 1 year ago
image
serioga commented 1 year ago

Workaround:

(declare thrown? thrown-with-msg?)
onetom commented 6 months ago

We have a generic test-harness NS, which we include into every test NS, which has that declaration, what @serioga mentioned.

We have also added (:require [our.test-harness :refer :all]) to the Settings→Editor→File and Code Templates→{Clojure,ClojureScript,CLJC} Test Namespace (documented here) template, to make sure we never see this warning.

The matcher combinators lib works this around by shipping with such declarations built-in here: https://github.com/nubank/matcher-combinators/blob/master/src/cljc/matcher_combinators/test.cljc#L22-L30

It would be nice to see some built-in solution from Cursive too.