lein-nsorg icon indicating copy to clipboard operation
lein-nsorg copied to clipboard

Static useless import removal?

Open piotr-yuxuan opened this issue 6 years ago • 6 comments

Hi! Thanks for this project, it's a nice tool to keep code clean. What would it take to remove unused or duplicate imports? Could this be done statically?

piotr-yuxuan avatar Apr 23 '18 22:04 piotr-yuxuan

Thanks for the feedback and improvement suggestions!

At least some duplicate imports would be really easy to catch when sorting, but some cases (e.g. requiring same namespace with different options) would require more work. I think would be still doable with static analysis. Thanks for the idea, I didn't even think about this 😊

I think it would be also possible to catch some unused imports statically but I don't think it possible to make it accurate with only static analysis. I have been thinking about using clojure/tools.analyzer for this but haven't started working on it yet: https://github.com/immoh/nsorg/issues/2

immoh avatar Apr 24 '18 04:04 immoh

Aw, so sad there is no analyzer for cljs :-(

piotr-yuxuan avatar Apr 24 '18 15:04 piotr-yuxuan

I didn't know tools.analyzer.js has been abandoned. However, it shoudn't require any knowledge about host to analyze and find unused imports so it must be possible some way.

immoh avatar Apr 25 '18 10:04 immoh

Just release 0.2.0 with duplicate removal.

immoh avatar Jun 25 '18 18:06 immoh

btw will you get to ClojuTRE in Helsinki this week? :-)

piotr-yuxuan avatar Sep 11 '18 19:09 piotr-yuxuan

@piotr-yuxuan I will be there

immoh avatar Sep 12 '18 11:09 immoh