-
Notifications
You must be signed in to change notification settings - Fork 66
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 Namespace is never user with namespaced keywords #211
Comments
Just a note that this is a significant problem as more namespace aliased keywords are added to code for clojure.spec declarations. |
As Eastwood is implemented right now, using tools.reader to read the source code, that library already converts What if soeone did this? (ns foo
(:require [bar.baz :as baz]))
(def x (:bar.baz/wibble ""}) Would you want to have no unused-namespace warning, even though the alias |
In this case the namespace might reasonably be said to be used even if not by the alias, and even though it's a keyword which doesn't require the namespace to exist before use. So I wouldn't report it as an unused namespace in your example. My goal was just to find I'm not sure if that fits what you thought could be easily implemented or not, hope it helps. |
The commit mentioned above looks for all uses of keywords in a namespace, after any Note that since this is done after macros are expanded, if a keyword appears in a macro expansion, it can cause a namespace to be considered used that way, even if the keyword with that namespace is in a macro definition in a different namespace. A bit indirect, but the only down-side in this case is that no warning is issued for that namespace being unused. If you want to try it out to see if it fixes the issue for you before the next Eastwood release, you can check out these instructions for locally installing an unreleased version of Eastwood from source code: https://github.com/jonase/eastwood#for-eastwood-developers |
The unused-namespaces linter doesn't recognise when a namespace is imported and its alias is used with a namespaced keyword, like so:
The text was updated successfully, but these errors were encountered: