HA.UNUSED

This checker reports on header files that are not used and can be removed.

The header analysis refactoring checkers (HA.*) detect unnecessary or missing transitive includes. Fixing header problems improves code maintainability.

How the header analysis refactoring checkers are used in Klocwork Desktop Analysis:

  • Klocwork Desktop C/C++ Plug-in for Visual Studio: These checkers are run as part of the desktop analysis, so that header issues appear in the issue list. If you disable one or more of these checkers, the relevant issues will not appear in your issue list, nor will the relevant refactorings be performed by the Optimize Headers menu option.
  • Klocwork Desktop C/C++ Plug-in for Eclipse: These checkers are not run as part of the desktop analysis, so header problems do not appear in the issue list. However, if you disable one or more of these checkers, the relevant issues will not be detected by the Analyze Headers and Optimize Headers menu options.
  • kwcheck for C/C++: These checkers are not used.
  • Klocwork Desktop for C/C++: These checkers are not used.

Vulnerable code example

Copy
#include <stdio.h>
#include <string.h> // HA.UNUSED: Header file 'string.h' is not used and can be removed.

int main(int argc, char *argv[]) {
  printf("argc=%d\n", argc);
  return 0;
} 

Related checkers