Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
February 08, 2016 How to warn of unused imports? | ||||
---|---|---|---|---|
| ||||
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? |
February 08, 2016 Re: How to warn of unused imports? | ||||
---|---|---|---|---|
| ||||
Posted in reply to cy | 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 |
February 08, 2016 Re: How to warn of unused imports? | ||||
---|---|---|---|---|
| ||||
Posted in reply to cy | 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.
|
February 08, 2016 Re: How to warn of unused imports? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adam D. Ruppe | 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
|
February 08, 2016 Re: How to warn of unused imports? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Kozak | 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. |
February 08, 2016 Re: How to warn of unused imports? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Basile B. | 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 |
February 09, 2016 Re: How to warn of unused imports? | ||||
---|---|---|---|---|
| ||||
Posted in reply to cy | 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.
|
February 09, 2016 Re: How to warn of unused imports? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Basile B. | 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...
|
February 09, 2016 Re: How to warn of unused imports? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Basile B. | 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. |
Copyright © 1999-2021 by the D Language Foundation