Identifying Unused Code

This tutorial demonstrates identifying unused code in an application. The example application has some code in it that is deliberately unused, so that we can demonstrate how to identify unused code.

  • Launch the sample application. Click on the launch icon on the toolbar. Alternatively to relaunch the most recently launched application, click the launch icon with a green recycle arrow around it
    Coverage Validator re-launch icon
  • If the launch icon is selected the Launch application dialog is displayed.
    Coverage Validator launch dialog

    • Select the sample application nativeExample.exe using the Browse… button, or select a previously executed application from the list at the bottom of the dialog.
    • Click the Go! button to launch the application.
    • The nativeExample.exe application is started.
  • If the relaunch icon is selected the most recently started application is started (for this tutorial we will assume this is nativeExample.exe).
  • Exercise as much of the application as possible. For this tutorial, the following actions should be peformed:
    • Help menu, About Coverage Validator Tester….
    • Test menu, Test 1.
    • Test menu, Test 2.
    • File menu, Exit.
  • At the end of the test it can be seen that one of the source code files has had no lines visited. This file is TestMemoryDialog.cpp.
    Coverage Validator unused code display
  • Further examination of this file shows that it contains the class CTestMemoryDialog. Searching the source code for the application shows that this class is not used anywhere. This indicates this class is most likely surplus to requirements and can be removed from the build.

Fully functional, free for 30 days