www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to get warnings about unused imports ?

reply "Gabi" <galim120 bezeqint.net> writes:
Hi,

How to find unused imports ?

It seems the compiler doesn't do it, but is there any other tool 
for that?
This seems like small issue, but those unused imports pile up 
pretty quickly

Regards,
Gabi
Jul 02 2013
parent reply "Namespace" <rswhite4 googlemail.com> writes:
On Tuesday, 2 July 2013 at 21:49:37 UTC, Gabi wrote:
 Hi,

 How to find unused imports ?

 It seems the compiler doesn't do it, but is there any other 
 tool for that?
 This seems like small issue, but those unused imports pile up 
 pretty quickly

 Regards,
 Gabi
I'm working on something like that for a few days. It is still not completely finished, but it works so far. But currently only for named imports. Everything else was far too much work for me. https://github.com/Dgame/SimpleDAT
Jul 02 2013
parent reply "Gabi" <galim120 bezeqint.net> writes:
On Wednesday, 3 July 2013 at 06:12:46 UTC, Namespace wrote:
 On Tuesday, 2 July 2013 at 21:49:37 UTC, Gabi wrote:
 Hi,

 How to find unused imports ?

 It seems the compiler doesn't do it, but is there any other 
 tool for that?
 This seems like small issue, but those unused imports pile up 
 pretty quickly

 Regards,
 Gabi
I'm working on something like that for a few days. It is still not completely finished, but it works so far. But currently only for named imports. Everything else was far too much work for me. https://github.com/Dgame/SimpleDAT
This is great. Maybe point me to the right direction how to implement finding unnamed imports too ? It could be great exercise for me to learn D :)
Jul 03 2013
parent "Namespace" <rswhite4 googlemail.com> writes:
You have to parse the unnamed import files, list all their 
identifiers (global variables, public functions etc.) and search 
for them. ;)
That could be a bit complicated. ;) Therefore I don't want to do 
it. Even with named imports you can get false positives.

But if you like it, you could improve it. The Lexer is my own and 
not that good, that would be start. On the wiki you can find 
other Lexer / Parsers, which are really good, but I haven't the 
time to replace my own and adapt the source or to work much on 
the project.
Jul 03 2013