www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to warn of unused imports?

reply cy <dlang verge.info.tm> writes:
When I factor out code from my modules, it really, really often 
leaves import statements that just sit there doing nothing, 
making it look like my program is more complex than it is. How do 
I get warned for leaving those, and a list of which ones I can 
safely remove?
Feb 08 2016
next sibling parent reply Daniel Kozak via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> writes:
V Mon, 08 Feb 2016 08:25:09 +0000
cy via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> napsáno:

 When I factor out code from my modules, it really, really often 
 leaves import statements that just sit there doing nothing, 
 making it look like my program is more complex than it is. How do 
 I get warned for leaving those, and a list of which ones I can 
 safely remove?
I dont think there is a way right now. But in a future dscanner. https://github.com/Hackerpilot/Dscanner/issues/134
Feb 08 2016
parent reply Basile B. <b2.temp gmx.com> writes:
On Monday, 8 February 2016 at 08:50:17 UTC, Daniel Kozak wrote:
 V Mon, 08 Feb 2016 08:25:09 +0000
 cy via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> 
 napsáno:

 When I factor out code from my modules, it really, really 
 often leaves import statements that just sit there doing 
 nothing, making it look like my program is more complex than 
 it is. How do I get warned for leaving those, and a list of 
 which ones I can safely remove?
I dont think there is a way right now. But in a future dscanner. https://github.com/Hackerpilot/Dscanner/issues/134
I don't think that Dscanner will be able to do this soon. Its scope is limited to a single module, it's not like DCD, which works with the imports and which is able to look-up elsewhere. For example you'll see this if you try to make an analyzer that produces warnings for signed & unsigned comparison. It impossible without a bit of semantic (ref: https://github.com/Hackerpilot/Dscanner/issues/204). Otherwise, it sounds like a decent enhancement request for DMD. I know other compilers who do this warning.
Feb 08 2016
parent reply cy <dlang verge.info.tm> writes:
On Monday, 8 February 2016 at 18:57:52 UTC, Basile B. wrote:

 Otherwise, it sounds like a decent enhancement request for DMD. 
 I know other compilers who do this warning.
It definitely does sound like a decent enhancement request. I didn't know it wasn't implemented yet, but it should be pretty straightforward, since within DMD you can access the AST. Alternatively, implementing DIP50 might let you do it outside the compiler. http://wiki.dlang.org/DIP50
Feb 08 2016
parent reply Basile B. <b2.temp gmx.com> writes:
On Monday, 8 February 2016 at 20:48:29 UTC, cy wrote:
 On Monday, 8 February 2016 at 18:57:52 UTC, Basile B. wrote:

 Otherwise, it sounds like a decent enhancement request for 
 DMD. I know other compilers who do this warning.
It definitely does sound like a decent enhancement request. I didn't know it wasn't implemented yet, but it should be pretty straightforward, since within DMD you can access the AST. Alternatively, implementing DIP50 might let you do it outside the compiler. http://wiki.dlang.org/DIP50
DIP50 is a "golem" It looks usefull, and it will help in many cases...but after a while it'll become a problem.
Feb 09 2016
parent reply Basile B. <b2.temp gmx.com> writes:
On Tuesday, 9 February 2016 at 15:21:59 UTC, Basile B. wrote:
 On Monday, 8 February 2016 at 20:48:29 UTC, cy wrote:
 On Monday, 8 February 2016 at 18:57:52 UTC, Basile B. wrote:

 Otherwise, it sounds like a decent enhancement request for 
 DMD. I know other compilers who do this warning.
It definitely does sound like a decent enhancement request. I didn't know it wasn't implemented yet, but it should be pretty straightforward, since within DMD you can access the AST. Alternatively, implementing DIP50 might let you do it outside the compiler. http://wiki.dlang.org/DIP50
DIP50 is a "golem" It looks usefull, and it will help in many cases...but after a while it'll become a problem.
If you don't understand what's a "golem": AlquiaDa was the golem of the CIA (in the 80's while russians were fighting in Afgnan). Useful until a certain point. Useful until a certain point...
Feb 09 2016
parent Basile B. <b2.temp gmx.com> writes:
On Tuesday, 9 February 2016 at 17:54:30 UTC, Basile B. wrote:
 On Tuesday, 9 February 2016 at 15:21:59 UTC, Basile B. wrote:
 On Monday, 8 February 2016 at 20:48:29 UTC, cy wrote:
 On Monday, 8 February 2016 at 18:57:52 UTC, Basile B. wrote:

 Otherwise, it sounds like a decent enhancement request for 
 DMD. I know other compilers who do this warning.
It definitely does sound like a decent enhancement request. I didn't know it wasn't implemented yet, but it should be pretty straightforward, since within DMD you can access the AST. Alternatively, implementing DIP50 might let you do it outside the compiler. http://wiki.dlang.org/DIP50
DIP50 is a "golem" It looks usefull, and it will help in many cases...but after a while it'll become a problem.
If you don't understand what's a "golem": AlquiaDa was the golem of the CIA (in the 80's while russians were fighting in Afgnan). Useful until a certain point. Useful until a certain point...
It's time for me to leave...once again alcool drives me crazy... Latest weeks I've been ofensive against two guys: kinsley and lopatim...it's time for me to leave. https://www.youtube.com/watch?v=6ixdPnLFVIo seeya.
Feb 09 2016
prev sibling parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Monday, 8 February 2016 at 08:25:09 UTC, cy wrote:
 How do I get warned for leaving those, and a list of which ones 
 I can safely remove?
Remove one, recompile. If it passes, leave it. If not, undo and move on to the next one.
Feb 08 2016
parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 02/08/2016 06:35 AM, Adam D. Ruppe wrote:
 On Monday, 8 February 2016 at 08:25:09 UTC, cy wrote:
 How do I get warned for leaving those, and a list of which ones I can
 safely remove?
Remove one, recompile. If it passes, leave it. If not, undo and move on to the next one.
Similarly, I comment out all; then uncomment one by one according to compilation errors. Ali
Feb 08 2016