-
Notifications
You must be signed in to change notification settings - Fork 69
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
clean-ns: false positives for symbol usage #239
Comments
i suppose you can use |
Thanks! That will help for the moment, had forgotten about the possibility. Anyway I hope the root cause can get solved eventually. I'd love to give it a shot myself, but can't at the moment. Busy life... |
We don't look for symbols in the metadata, which is why this isn't handled. I'm not sure how much slower this would be, if we also looked at the metadata of everything. It might not be worth it to to handle this in general. In other words, to avoid not making There's a half-finished PR in this repo about adding metadata to keep certain symbols from getting cleaned out. So that would be another solution to this. At work I've used a third solution: I have one or two namespace forms that are immediately followed by a Thanks for the report! |
Gotchu! Just let me make sure - wouldn't it be pretty fast to just e.g. for Admittedly this wouldn't be as powerful as a proper code analysis, but I think it'd work, with few possible false positives/negatives. I'd say that it's better to err on the side of caution (don't strip requires because of a spurious match) than the opposite (strip requires because of a non-exhaustive search). |
Yes, that would be super fast. We did this in the first version of Anyway, the only reason this isn't working is because I didn't know anyone was referencing external symbols in their metadata when I implemented |
:) May I know if it is likely that this will get it fixed? Perhaps it's a matter of git archeology, recovering the old approach and adding to the current behavior (perhaps optionally). Can give it a shot if you don't foresee personal availability. |
I won't have time to implement this myself, but I'd be happy to help with code review or to answer any questions you might have if you give it a shot yourself.
You can certainly find this. It's in the
We moved away from the old approach for a reason :p It was buggy and the implementation was getting to be super convoluted, so I'd rather extend the current implementation with better support for metadata than revive the old one. |
Thanks for the info! Appreciated. I could implement a metadata-safe "used-namespaces" function, using it as a whitelist when interacting with refactor-nrepl. It's working fine. In a couple weeks after some due battle-testing I'll be able to open-source it and open a PR. |
We already have this in |
Thanks for the pointer! I was aware of the whitelist option, but it didn't occur to me that I could pass different whitelists on a per-file basis. That simplified my implementation :) |
The performance hit in considering literally every piece of metadata shouldn't be too detrimental so we'll just err on the side of caution for now.
The performance hit in considering literally every piece of metadata shouldn't be too detrimental so we'll just err on the side of caution for now.
The performance hit in considering literally every piece of metadata shouldn't be too detrimental so we'll just err on the side of caution for now.
The performance hit in considering literally every piece of metadata shouldn't be too detrimental so we'll just err on the side of caution for now.
The performance hit in considering literally every piece of metadata shouldn't be too detrimental so we'll just err on the side of caution for now.
The performance hit in considering literally every piece of metadata shouldn't be too detrimental so we'll just err on the side of caution for now.
Hi!
Sometimes I may want to
:require
something just for using the alias later for symbol construction, with no var usage.For example:
The above is a vanilla usage of metadata-based protocol extension, a new Clojure 1.10 feature.
If the ns didn't use
xyz
for any vars,clean-ns
will wipe the require. And Clojure won't complain when compiling the ns again, since:...is always a valid token.
Thanks - Victor
The text was updated successfully, but these errors were encountered: