Skip to content

Commit

Permalink
sonarcloud: Use Inclusions Property (#121)
Browse files Browse the repository at this point in the history
Fixes code coverage builds by switching to using the sonar.inclusions
property.

Some of our build targets set their source directories in the include paths.
Those paths are then emitted in the sonar-project.properties file here. The
issue is that this can lead to files being indexed twice which the sonar-scanner
treats as an error.

Using the `sonar.inclusions` property and adding pattern strings avoids this
issue.
  • Loading branch information
jungleraptor authored and krisukox committed Aug 2, 2022
1 parent 3550197 commit 89a30fb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Sonarcloud.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,11 @@ function(generate_sonarcloud_project_properties sonarcloud_project_properties_pa
set(sonarcloud_project_properties_content "sonar.sourceEncoding=UTF-8\n")

set(source_files ${source_source_files} ${source_include_directories} ${test_source_files})
foreach (dir ${source_include_directories})
set(source_files ${source_files} ${dir}/*.h ${dir}/**/*.h)
endforeach()
list(JOIN source_files ",${_sonarcloud_newline}" sonar_sources)
string(APPEND sonarcloud_project_properties_content "sonar.sources=${_sonarcloud_newline}${sonar_sources}\n")
string(APPEND sonarcloud_project_properties_content "sonar.inclusions=${_sonarcloud_newline}${sonar_sources}\n")

file(GENERATE
OUTPUT "${sonarcloud_project_properties_path}"
Expand Down

0 comments on commit 89a30fb

Please sign in to comment.