Question

Does anyone know of a methodology that can be used on a project file tree to identify dead files, dead code, unused libraries, etc. I have been thinking about this for some time as I seem to inherit code that was develop from another code base and find that my maintenance reveals unneeded libs, unused files and last of all dead code.

Was it helpful?

Solution

Unfortunately, nearly all languages allow for runtime loading of code and/or reflection which make full static analysis impossible because the code could be used dynamically. Though those tools exist for most languages if you’re willing to live with that caveat - not a few languages/IDEs do this sort of dead code/reference analysis these days and emit warnings.

Full runtime analysis is impossible because it’s equivalent to the halting problem (is that code really dead, or has it just not been called yet?). Though those tools exist if you’re willing to live with that caveat. Depending on your situation, a simple code coverage tool (perhaps in combination with a fuzzer) might be sufficient, which come with many testing frameworks.

Licensed under: CC-BY-SA with attribution
scroll top