Some .h files not analyzed

Hello,
we are using SonarQube 10.0.0.68432.

We noticed an issue that some of our include files (available in a shared central directory “Includes”) are analyzed, while other are ignored. All of the files are used/included somewhere inside our project (are included using #include statements), but not all of them are added to a project file directly.

Is it required for a .h file to be at least directly added to one vcxproj file to be analyzed by SQ?
What is the best way to find out why a file is excluded?
Those files are typically .h files wihout an implementation file (cpp) - could that contribute?

What information can we check/generate and how to get further debugging information?

Thanks!

Hey there.

Are you using the Scanner for .NET or the SonarScanner CLI?

SonarScanner CLI

Hi @Wolfgang_Gogg ,

compilation units compiled during your build are the entry points to analyze header files. This means, that if you have some header files which are not included by any of the files built in your project (directly or indirectly) then they won’t be analyzed.

Hello, the header files are included by files which are part of the build. But they are not directly added to any of the vcxproj files. It seems then they are ignored?!
I tested with adding them explicitly to an arbitrary vcxproj and as soon as i did so it was analyzed.
Is this how it is supposed to work?
Thanks!

For a header file to be analyzed, the following conditions must be met:

  • The header files should be included by one of the compilation units of the build.
  • Both the compilation units and the header files should be part of the files indexed by the sonar-scanner-cli. They both should appear in the folder specified in sonar.sources property. (important note: sonar.tests folders are not considered by the analysis of C/C++ files, test folders should be part of sonar.sources set)

If you want to be sure that your header files are indexed you can add --verbose to your sonar-scanner arguments and check the list of indexed files.

If you are still not able to figure out the mismatch after this explanation, I can send you a private message where you can share the analysis log and additional information so I can have a look.

Hello, happy to share logs as unfortunately none of the above explanation seems to really fit to our case. Please share where i can send the logs to. Thanks!

Hi @Wolfgang_Gogg ,

thank you for the logs, the reason why what I explained didn’t work is that you are not using the sonar-scanner cli as mentioned above, you are using the SonarScanner for MSBuild which controls the set of indexed files. This is why when you add them to a vcxproj then they are indexed.

Hi, sorry for the incorrect information from my side. So this is then as designed?

Yes, this is expected, the SonarScanner for MSBuild set the list of indexed files to the project files. If you look at your logs you can see that sonar.sources is set to a list of files rather than to a folder.

Hi @Wolfgang_Gogg ,

can I consider this topic closed?

Yes, thanks

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.