How can I get SonarQube to analyse C++ (& C) Header Files?

Hello Thomas,

What indicator do you use to detect that headers are not analyzed?

Normally, you should not have to do anything to have your header files analyzed: Headers are not autonomous files. They only make sense in the context of a source file in which they are included. And a source file can only make sense with its included headers. Therefore, this leads to two conclusions:

  • What needs to be configured for analysis is source files only. All the (recursively) included files will be analyzed along with the source file.
  • If a header file is not included (even recursively) in any source file, it is effectively dead code, and will not be analyzed.

Thank you