C++ header files not visible


I am using SonarCloud via GitLab CI to analyse a C++ project. This project will be a template library so it’s important that the headers are scanned. I cannot, however, get the header files to show up in the analysis; they are completely ignored. I have a dummy.cpp file that I intend to use just to include the header files needing analysed but this does not appear to solve anything. Currently my branch “main” has nothing as I have been working on this feature in a merge request and thus all links below will point to the relevant tree and merge request.

CI System



SonarCloud displays header files with analysis results


Header files are missing from the analysis


Build: sonar_build
Sonar check upload: sonar_upload


I hope I am just missing some very simple configuration somewhere as it does seem to work for others.



[EDIT]: logs expired; replaced the links with more permanent links

I’ve done a little more digging in the logs and I definitely see references to dummy.h being scanned and there is nothing about this file being excluded. I am genuinely stumped. For example, I have compared with https://github.com/Hamdor/task which is also a C++ project using SonarCloud. While I can find no meaningful differences in the CI configurations this project has managed to have it’s header files displayed in the Sonar UI.

Is there anyone that can find something obvious that I am missing?


It was the inline keyword… Compiler inclined the function and it disappeared from all TUs. Non-inlined and function template versions yield a header file in the UI. Marking as solved…


Hello @DavidBrown,

I’lm glad that you managed to sort out your issue. I’d just like to mention that you may have missed a part of the UI that might have helped you:
It’s possible to list all indexed files in the project, by clicking on code:

and this can list your header, even if it only contains only inlined functions.

hello @DavidBrown,

I’m think you are wrong. The content of a header file shouldn’t impact if it is part of the anlysis or the “Code” Display.

  • A header file is analyzed if it is included in one of the translation units compiled by the build-wrapper command.
  • If a file(including header) show up in the analysis result depends on the type of the analysis(main branch/pull reques/short-lived).
    I think the issue is just a misunderstanding of what kind of issue/code is displayed with “merge request” and short-lived branch.
    So for these the “Code” display show “new code” and new code is:

For short-lived branches, the new code consists of all those files which have been modified or added relative to the target branch. Modified files are determined by comparing checksums between the sonar.branch.target branch and the short-lived branch to be analyzed.

In your case your target branch is the “main” branch.
I believe in your first try dummy.h was not modified compared to the main branch and that why it didn’t show up. and you actually “fix” it by modfying it (removing the inline keyword) which made it show up since it now contains new code.

Note: you have to analyze the main branch so that only issues in the Merge request but not in the main branch appear.

For more details see:

Let me know if you have further questions,

1 Like

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