Identifying Extraneous Code

As a project goes through its life-span some code invariable gets relegated to the trash. Here are some quick ways of identifying code that might be a good candidate for deletion. All of these methods come with the caveat that your project definition is accurate. More details on improving accuracy here:

Highlight in Editor

The quickest and easiest approach is turning on the “Highlight Unused Entities” option in Tools->Options->Editor->Advanced. This will highlight entities (gray by default) that are not referenced elsewhere in the project.



Dead Code Script

There is an API script that ships with Understand (SciTools\scripts\perl\ for finding dead code.  More information on running scripts in Understand can be found here. Basically navigate to the script in Tools->Run a command and make sure the “STI Perl Script” checkbox is run and list the root functions (e.g. main) that your program uses. Understand will walk through the call trees for each of those specified functions and then list the functions that are not in any of those call trees.




The HTML and Text reports generated by Understand have areas for reporting many unused objects. These can be accessed via the Reports menu. These reports are currently being re-written so the format is subject to change.

unused reports



CodeCheck has hundreds of checks designed to look for different violations and deviations from a specified standard. Here are some of extraneous things Codecheck can help identify:

  • Unreachable Code – Code that is never executed such as a code after a return statement
  • Unused Functions – Functions that are never called as part of the primary call trees
  • Unnecessary #includes
  • Commented-Out Code
  • Unused Local Variables
  • Unused Static Globals
  • Unused Parameters