How to warn of unused imports?

Basile B. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 8 10:57:52 PST 2016


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 at 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.


More information about the Digitalmars-d-learn mailing list