TransWikia.com

Code Base Analysis

Software Engineering Asked by abz.b on December 4, 2021

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.

One Answer

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.

Answered by Telastyn on December 4, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP