Skip to content

Commit

Permalink
Fix Sonarcloud sonar-project.properties (#120)
Browse files Browse the repository at this point in the history
Fixes the emitted sonar.properties file so that header and test files
are picked up by Sonarcloud analysis.

According to the docs `sonar.tests` is ignored for C/C++ code, so
test paths should be treated the same as source paths.

Also switches `sonar.inclusions` with `sonar.sources` to fix the include
paths being filtered out.
  • Loading branch information
jungleraptor authored Jul 15, 2022
1 parent 62f063f commit 3550197
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Sonarcloud.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,9 @@ 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})
set(source_files ${source_source_files} ${source_include_directories} ${test_source_files})
list(JOIN source_files ",${_sonarcloud_newline}" sonar_sources)
string(APPEND sonarcloud_project_properties_content "sonar.inclusions=${_sonarcloud_newline}${sonar_sources}\n")

set(test_files ${test_source_files})
list(JOIN test_files ",${_sonarcloud_newline}" sonar_tests)
string(APPEND sonarcloud_project_properties_content "sonar.tests.inclusions=${_sonarcloud_newline}${sonar_tests}\n")
string(APPEND sonarcloud_project_properties_content "sonar.sources=${_sonarcloud_newline}${sonar_sources}\n")

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

0 comments on commit 3550197

Please sign in to comment.