ctl icon indicating copy to clipboard operation
ctl copied to clipboard

Feature request: dead module / file detection

Open jcward opened this issue 7 years ago • 5 comments

One aspect of a large codebases is the potential for files to simply never be included in the build in the first place. This macro doesn't pick those up, obviously, because they aren't part of the build. However, "dead module detection" is arguably as useful as "dead code detection."

Thought 1) Perhaps an easy way would be using the Compiler include macro for "all packages", maybe:

--macro include('')

But this actually doesn't work... It seems to be implying -cp . as it results in "invalid package" errors...

Thought 2) Perhaps another idea is to actually glob from all source paths in TCell.hx, and report unused modules / files from there.

Thought 3) Just mention in the README, this doesn't pick up types that are never referenced.

jcward avatar Apr 09 '18 14:04 jcward

I can add an option to let the macro scan all classpaths and report any modules that the compiler doesn't see.

back2dos avatar Apr 09 '18 15:04 back2dos

One of the potential problem of --macro include is that it forces the compiler to compile all those dead/orphan class which in turn forces the user to fix all the compiler error there. That is not desirable I suppose.

kevinresol avatar Apr 16 '18 10:04 kevinresol

it forces the compiler to compile all those dead/orphan class which in turn forces the user to fix all the compiler error there.

Well, I think that's the goal: to make the user fix or eliminate (or minimally, aware of) his dead code. But this is probably best optional -- in case it's a daunting task.

jcward avatar Apr 16 '18 14:04 jcward

In that case, you don't need this library?

kevinresol avatar Apr 16 '18 14:04 kevinresol

@kevinresol - I feel like we're not communicating well via these comments, but that we're actually in agreement. :+1: I'm merely saying:

An option to scan and include all orphan modules would complement this library (and its goal of code cleanup) nicely. Perhaps not as the default, as that could overwhelm the user on the first try, but certainly as an option.

jcward avatar Apr 17 '18 17:04 jcward