Warn on unused imports?
Neia Neutuladh
neia at ikeran.org
Wed Sep 26 16:29:24 UTC 2018
On 09/26/2018 02:51 AM, FeepingCreature wrote:
> On Wednesday, 26 September 2018 at 08:37:12 UTC, Dejan Lekic wrote:
>> I humbly believe this does not belong to the compiler. These sort of
>> things belong to a static code analyser TOOL. Think of
>> checkstyle/findbugs in Java, or flake8/pep8 in Python world.
>
> I can't put it differently than this: you're simply wrong, in my
> opinion. It's *provably impossible* do do this statically.
I think you can do some amount of it statically:
* List out the symbols each module exports.
* List out the symbols that appear in source code.
* If you find that a module doesn't export a symbol that this code uses,
recommend its deletion.
* If you encounter a mixin in a module that's visible to it, assume that
module is required. (Optional: require that mixin to be at module scope.)
* If you encounter a mixin in the module you're analyzing, give up.
So that's at least 80 modules in Phobos that you might be able to
suggest not importing.
More information about the Digitalmars-d
mailing list