-
Notifications
You must be signed in to change notification settings - Fork 2
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
Namespaced keyword usage linter #89
Comments
How would one determine the 'existence' of a keyword in a certain ns? Just as a spec (using |
No, I wouldn't couple the linter to Spec in any way Given a ns reference such as Armed with that source, one can perform a simple scan of keywords with |
played around with this a bit. The bit from file -> keywords. (->> (str "[" (slurp source) "]")
(tools.reader/read-string {:read-cond :preserve
:features #{:clj :cljs}})
(flatten)
(filter #(and (keyword? %)
(= (str *ns*)
(namespace %))))
(map name))
=>
'("local-name"
"binding-form"
"local-name"
"seq-binding-form"
"map-binding-form"
"seq-binding-form"
"binding-form"
...) still need to figure out how to resolve |
I guess part of the difficuly lies in that you cannot know in advance if the filename is .clj, .cljs, .cljc or multiple of those; particularly without performing a Perhaps one can try the three extensions sequentially, build a set out of each maybe-file, and finally merge those sets. |
Context
Some codebases use ns-qualifed keywords heavily, including cross-ns keyword references.
Such a pattern is subject to bugs:
Task
Create a linter that fails when consumed keywords don't exist in the producer side.
The text was updated successfully, but these errors were encountered: