DCE as a repository cleanup tool?

We have a Haxe project that is showing some age spots, there are dead areas in the code that would be nice to find and validate if they should be removed. Does anyone know of a way to dump out what Haxe Dead Code Elimination sees?

It would be great to have a list of classes, functions, and typedefs (and typedef fields!) that are not directly accessed during compile time. We would want to manually verify they are not accessed via Reflect, but in general this would be a huge time saver and it looks like something the compiler is already doing.

Any tips are very welcome, thanks!

There is --dce_debug compiler flag for some part of it.

If you are using Visual Studio Code with vshaxe extension (if you aren’t, you should), then you can enable Code Lens. Local variables/imports that aren’t in use are also grayed out. Although the compiler isn’t yet perfect in all this in my experience (probably due to heavy macro use on my side), but it does work. :slight_smile:

You may also find this lib helpful: GitHub - back2dos/ctl: Cytotoxic T cells for your codebase.

1 Like