Why might "C++ AutoConfig is discouraged for this project" displayed? (SQ 2025.4.2)

Must-share information (formatted with Markdown):

  • which versions are you using (/ Community Build, Scanner, Plugin, and any relevant extension) SonarQube Server Developer Edition 2025.4.2
  • how is SonarQube deployed: zip
  • what are you trying to achieve
    I get the following warning displayed in SQ server for the build of an mixed C++/C# solution.

C and C++ AutoConfig is discouraged for this project. Consider setting the properties in Project Administration > General Settings > C / C++ / Objective-C > AutoConfig Settings. Otherwise, please switch to Compilation Database based analysis for better analysis quality.

  • what have you tried so far to achieve this
    Build is done in Azure Pipeline with vsbuild@1 and C++ properties in SonarQubePrepare@7 task. Target is Windows. (4 C# and 13++ projects are in the solution.)

    sonar.cfamily.vscoveragexml.reportsPath=$(Agent.TempDirectory)/**/*.coveragexml
    sonar.cfamily.generateComputedConfig=true
    sonar.cfamily.reportingCppStandardOverride=c++23
    sonar.cfamily.enableModules=true
    

I want to understand, what might be the reasons that AutoConfig is discouraged and if I can fix it.

Hi @milbrandt ,

this means that the analyzer was not able to analyze the C and C++ files with a good enough quality, likely due to missing header files or macros.

Would you be able to share a bit more about your project? I can eventually send you a private message where you can share privately.

Hi @mpaladin

as mentioned by the properties, it is C++23 code mainly with modules. Therefore there are only very few header files.
Google test is used as testing framework and test coverage largly reported to SonarQube (not all covered code unfortunately, e.g. static methods are not marked in SQ).
It is a mixed solution with C# where LibraryImport attribute is used to consume the C++ DLL.

Currently there are files (including tests)

extension number size
cs 15 (13 w/o tests) 12 kB (10 kB w/o tests)
ixx 48 131 kB
cpp 35 (8 without tests) 169 kB (73 kB w/o tests)
h 3 3 kB

The complete solution is build at once. Relevant parts for C++ of the build pipeline are:

    - task: SonarQubePrepare@7
      displayName: 'Prepare analysis on SonarQube'
      inputs:
        SonarQube: Sonarqube
        projectKey: XXX
        projectVersion: '$(Build.BuildNumber)'
        extraProperties: |
          sonar.exclusions=external/**
          sonar.cs.opencover.reportsPaths=$(Agent.TempDirectory)/**/*.opencover.xml
          sonar.cs.vstest.reportsPaths=$(Agent.TempDirectory)/**/*.trx
          sonar.cfamily.vscoveragexml.reportsPath=$(Agent.TempDirectory)/**/*.coveragexml
          sonar.junit.reportPaths=**/test_details.xml
          sonar.cfamily.generateComputedConfig=true
          sonar.cfamily.reportingCppStandardOverride=c++23
          sonar.cfamily.enableModules=true

    - task: VSBuild@1
      displayName: "Build solution with VSBuild"
      inputs:
        solution: '**\*.sln' 
        configuration: "$(BuildConfiguration)"
        clean: true 
        msbuildArchitecture: 'x64'

    - task: NuGetCommand@2
      displayName: 'NuGet install GoogleTestAdapter'
      inputs:
        command: 'custom' 
        arguments: "install GoogleTestAdapter -OutputDirectory $(Build.BinariesDirectory) -ExcludeVersion"

    - task: VSTest@3
      displayName: 'Run Google C++ unit tests'
      inputs:
        testSelector: 'testAssemblies'
        testAssemblyVer2: "source/x64/**/*Test.exe"
        searchFolder: '$(System.DefaultWorkingDirectory)' 
        pathtoCustomTestAdapters: "$(Build.BinariesDirectory)/GoogleTestAdapter"
        codeCoverageEnabled: True
        resultsFolder: $(Agent.TempDirectory)\TestResults\gtest
        testRunTitle: "Google Test C++"

    - task: SonarQubeAnalyze@7
      displayName: 'Complete the SonarQube analysis'

    - task: SonarQubePublish@7
      displayName: 'Publish Quality Gate Result'

Log files or more details I can share only privately. Which additonal information would be meaningful for analysis?

Hi @milbrandt ,

C++ modules are not enabled by default, its support is experimental, you can have a look at the documentation:

You can try to enable them, if you face problems you could try to have a look at manual analysis.

Modules I have already enabled: sonar.cfamily.enableModules=true But I’ll read the linked docs again, maybe I can find something additional.

A colleague also discovered roday that code coverage behaves like a “random number generator” - a lot of lines are not color marked in the code view of SQ, and the covered lines can also change.

Hi @milbrandt ,

if the quality index keeps low you are likely not going to have a lot of value out of your analysis.

I would double check that the ingested data is correct and that it is not blinking.