diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d150ced..c7d5239 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -839,6 +839,17 @@ jobs: ls -la sonar-project.properties || echo "sonar-project.properties not found" ls -la coverage.xml coverage.lcov 2>/dev/null || echo "Coverage files not found" + # Ensure compile_commands.json is available for C++ analysis + if [ -f build/compile_commands.json ]; then + echo "Copying compile_commands.json from build/ to root" + cp build/compile_commands.json . || echo "Failed to copy compile_commands.json" + elif [ -f compile_commands.json ]; then + echo "compile_commands.json already exists in root" + else + echo "WARNING: compile_commands.json not found! C++ analysis may be limited." + fi + ls -la compile_commands.json 2>/dev/null || echo "compile_commands.json not found" + echo "=== Checking coverage file formats ===" if [ -f coverage.lcov ]; then echo "--- coverage.lcov (first 10 lines) ---" @@ -872,9 +883,12 @@ jobs: -Dsonar.test.inclusions=**/*_test.cpp,**/test_*.cpp,tests/**/*.cpp \ -Dsonar.exclusions=**/OgreXML/**,**/dependencies/**,**/*_autogen/**,**/CMakeFiles/**,**/ui_files/**,**/moc_*,**/_deps/** \ -Dsonar.coverage.exclusions=**/*_test.cpp,**/test_*.cpp,tests/**/*.cpp,tests/**/*.qml,**/*_autogen/** \ - -Dsonar.c.file.suffixes=.c \ - -Dsonar.cpp.file.suffixes=.cpp,.cc,.cxx,.c++,.hpp,.hh,.hxx,.h++ \ + -Dsonar.c.file.suffixes=.c,.h \ + -Dsonar.cpp.file.suffixes=.cpp,.cc,.cxx,.c++,.hpp,.hh,.hxx,.h++,.h \ -Dsonar.objc.file.suffixes=.m,.mm \ + -Dsonar.cfamily.compile-commands=compile_commands.json \ + -Dsonar.cfamily.cache.enabled=true \ + -Dsonar.cfamily.threads=4 \ -Dsonar.verbose=true" # Add build-wrapper output if it exists diff --git a/sonar-project.properties b/sonar-project.properties index 2f5b001..3e09e88 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -24,14 +24,17 @@ sonar.exclusions=**/OgreXML/**,**/dependencies/**,**/*_autogen/**,**/CMakeFiles/ # Coverage exclusions - exclude test files from coverage calculation sonar.coverage.exclusions=**/*_test.cpp,**/test_*.cpp,tests/**/*.cpp,tests/**/*.qml,**/*_autogen/** -# Coverage settings for C++ projects without cfamily plugin -# Note: Generic coverage support in SonarQube is limited for C++ -# Coverage path will be set dynamically in workflow to ensure file exists -# If coverage reporting doesn't work, you may need to use the sonar-cxx community plugin +# Coverage settings for C++ projects +# Note: Coverage path will be set dynamically in workflow to ensure file exists # Enable C++ file analysis with build-wrapper support # The build-wrapper provides compilation data for SonarCloud analysis # File suffixes for C/C++ source files -sonar.c.file.suffixes=.c -sonar.cpp.file.suffixes=.cpp,.cc,.cxx,.c++,.hpp,.hh,.hxx,.h++ +sonar.c.file.suffixes=.c,.h +sonar.cpp.file.suffixes=.cpp,.cc,.cxx,.c++,.hpp,.hh,.hxx,.h++,.h sonar.objc.file.suffixes=.m,.mm + +# C++ analysis configuration using compile_commands.json for better analysis +sonar.cfamily.compile-commands=compile_commands.json +sonar.cfamily.cache.enabled=true +sonar.cfamily.threads=4