SonarCloud does not include code from a project directory in analysis

  • Command used: sonar-scanner

  • The project is written in C++

  • Our project has this directory structure




  • We use cmake to generate a compile_commands.json in top_level_directory for sub_project_2

cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 project/sub_project_2

  • The sonar-scanner runs in top_level_directory so it can see other_project_code and project

  • The contains these settings and is in top_level_directory



  • The compile_commands.json does contain file names inside of other_project_code/source

  • After the sonar-scanner runs, the analysis results don’t show any code from inside of other_project_code/source

  • I have also tried compiling both sub_project_1 and sub_project_2 from top_level_directory with the Sonar build wrapper and still did not see any code from other_project_code/source in the analysis

  • I am not sure where to go from here, possibly adding the sonar.include setting? Any help is much appreciated. Thank You

Hey there.

Are the files being indexed by the scanner? You can see which files are indexed running sonar-scanner -X

Thank you for the great suggestion, the files are being indexed by sonar-scanner. After running it with the -X option, I see that the files I want in other_project_code/source are being excluded by the scm ignore settings. For context, the other_project_code is a git submodule so I’d imagine there is something sonar-scanner is finding (maybe the .gitmodules file? The .gitignore did not have any reference to other_project_code) that makes it ignore that directory.

This is great! Way more information than I had before. Thank you for the reply. If you have any other ideas on how to get sonar-scanner to disregard the scm ignore settings that would be awesome!

I was able to get the code to show up in the analysis! I tried removing the .gitmodules file and the .git/modules/other_project_code directory with no success. What ended up solving the problem was running sonar-scanner -Dsonar.scm.exclusions.disabled=true

Thank you for the help!

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