Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive suspicious-expression #207

Closed
emlyn opened this issue Nov 3, 2016 · 2 comments · Fixed by #373
Closed

False positive suspicious-expression #207

emlyn opened this issue Nov 3, 2016 · 2 comments · Fixed by #373

Comments

@emlyn
Copy link
Contributor

emlyn commented Nov 3, 2016

The following code:

(ns testing.core-test
  (:require [clojure.test :refer :all]
            [testing.core :refer :all]))

(defn func [f] "")

(deftest b-test
  (is (instance? String (func +))))

Causes the following failure:

== Eastwood 0.2.2 Clojure 1.8.0 JVM 1.8.0_31
Directories scanned for source files:
  src test
== Linting testing.core ==
== Linting testing.core-test ==
Entering directory `/Users/emlyn/testing'
test/testing/core_test.clj:8:7: suspicious-expression: + called with 0 args.  (+) always returns 0.  Perhaps there are misplaced parentheses?
== Warnings: 1 (not including reflection warnings)  Exceptions thrown: 0
Subprocess failed

Even though the + is never called.

@emlyn
Copy link
Contributor Author

emlyn commented Nov 8, 2016

Also, changing func to actually call f, e.g.

(defn func [f]
  (str (f 1 2)))

(deftest b-test
  (is (instance? String (func +))))

Still fails with "suspicious-expression: + called with 0 args", even though it is only ever called with 2 args.

@emlyn
Copy link
Contributor Author

emlyn commented Nov 9, 2016

I tried adding a config file with:

(disable-warning
 {:linter :suspicious-expression
  :for-macro 'clojure.core/+
  :if-inside-macroexpansion-of #{'clojure.test/is}})

But it doesn't suppress this warning, is it because + is not a macro? Any way I can fix it?

vemv added a commit to reducecombine/eastwood that referenced this issue May 1, 2021
Close jonase#116 (nothing had to be fixed; only proves that the bug is now absent)
Fixes jonase#207
Fixes jonase#313
vemv added a commit to reducecombine/eastwood that referenced this issue May 1, 2021
Close jonase#116 (nothing had to be fixed; only proves that the bug is now absent)
Fixes jonase#207
Fixes jonase#313
slipset pushed a commit that referenced this issue May 1, 2021
Close #116 (nothing had to be fixed; only proves that the bug is now absent)
Fixes #207
Fixes #313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant