Skip to content

Supported configuration properties

guwirth edited this page Mar 10, 2021 · 77 revisions

This description is only valid for cxx plugin version 1.x

The cxx plugin uses the following properties during analysis. See here for the ways how to pass them to the cxx plugin.

Beside the general SonarQube Analysis Parameters the latest released cxx plugin supports the parameter below:


sonar.cxx.suffixes.sources

Scope: system, project
Default: .cxx,.cpp,.cc,.c

Comma separated list of file name extensions to be considered as C++ source files during analysis.

Example:


sonar.cxx.suffixes.headers

Scope: system, project
Default: .hxx,.hpp,.hh,.h

Comma separated list of file name extensions to be considered as C++ header files during analysis.

Example:


sonar.cxx.includeDirectories

Scope: system, project
Default: ---

Comma separated list of directories where the cxx plugin will be looking for included files.

  • Note: the cxx plugin doesn't know any standard include paths. If they should be used, configure them manually using this property.


*Example:* `include, /usr/include`

sonar.cxx.forceIncludes

Scope: system, project
Default: ---

Comma separated list of header files to be implicitly included at the beginning of each source file, for details see Force Include

Example: VS10Macros.h


sonar.cxx.defines

Scope: system, project
Default: ---

List of macros which should be used during analysis. The syntax is the same the body of #define-directives, except the #define keyword itself. This is a multiline property, which means:

  • If you're using SonarQube's UI just write a macro per line
  • When setting via .properties-file separate macros using \n\

*Example:*
va_arg(a, b) 0, \n\
PRIx64 ""       \n\
DEBUG 1

sonar.cxx.cFilesPatterns

Scope: project
Default: *.c,*.C

Comma-separated list of wildcard patterns used to detect C files. When a file matches any of the patterns, it is parsed in C-compatibility mode.

Example:


sonar.cxx.errorRecoveryEnabled

Scope: project, module
Default: True

Defines tolerant or strict error handling mode. This setting has impact on parsing the source files and reading report files:

  • report files:
  • error in an report file could be for example invalid file references or line numbers
  • in tolerant mode (True) analysis continue in case of errors in a report file
  • in strict mode (False) an error in a report file will stop the analysis
  • source code parsing:
  • parsing error means that source code file does not fit to C/C++ grammar
  • in tolerant mode (True) syntax errors within a declaration are skipped, analysis is continued with next declaration in source code file. For details see Error Recovery.
  • in strict mode (False) analysis of source code file fails after an syntax error. Source code file is ignored.

*Example:* `sonar.cxx.errorRecoveryEnabled=True`

sonar.cxx.cpd.ignoreLiterals

Scope: project, module
Default: False

CPD ignores literal value differences when evaluating a duplicate block. This means that foo=42; and foo=43; will be seen as equivalent.

Example: sonar.cxx.cpd.ignoreLiterals=False

sonar.cxx.cpd.ignoreIdentifiers

Scope: project, module
Default: False

CPD ignores identifier value differences when evaluating a duplicate block.; i.e., variable names, methods names, and so forth.

Example: sonar.cxx.cpd.ignoreIdentifiers=True


sonar.cxx.cppcheck.reportPath

Scope: project
Default: ---

Ant pattern describing the path to Cppcheck reports. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.rats.reportPath

Scope: project
Default: ---

Ant pattern describing the path to RATS reports. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.valgrind.reportPath

Scope: project
Default: ---

Ant pattern describing the path to Valgrind reports. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.vera.reportPath

Scope: project
Default: ---

Ant pattern describing the path to Vera++ reports. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.drmemory.reportPath

Scope: project
Default: ---

Ant pattern describing the path to Dr Memory reports. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.xunit.reportPath

Scope: project
Default: ---

Ant pattern describing the path to unit test execution reports. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.xunit.xsltURL

Scope: project
Default: ---

A name of a built in XSLT-file or an URL to an external one. Available builtins:

  • boosttest-1.x-to-junit-1.0.xsl: For transforming Boost-reports
  • boosttest-1.x-to-junit-dummy-1.0.xsl: For transforming Boost-reports, simulating virtual files
  • cpptestunit-1.x-to-junit-1.0.xsl: For transforming CppTestUnit-reports
  • cppunit-1.x-to-junit-1.0.xsl: For transforming CppUnit-reports


*Example*: `cppunit-1.x-to-junit-1.0.xsl`

sonar.cxx.xunit.provideDetails

Scope: project
Default: False
History: no more supported with v0.9.7+

If "True", tries to assign testcases in reports to test resources in SonarQube, thus making the drilldown to details possible

Example:


sonar.cxx.vstest.reportsPaths

Scope: project
Default: ---

Ant pattern describing the path to unit test execution reports. TRX output from VSTest. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.nunit.reportsPaths

Scope: project
Default: ---

Ant pattern describing the path to unit test execution reports. XML output from the NUnit console runner. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.xunit.reportsPaths

Scope: project

Default: ---

Ant pattern describing the path to unit test execution reports (XUnit XML output). Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.pclint.reportPath

Scope: project
Default: ---

Ant pattern describing the path to PC-lint reports. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.other.reportPath

Scope: project
Default: ---

Ant pattern describing the path to other reports. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.other.sqales

Scope: project
Default: ---
History: no more supported with v0.9.6+

SQALE characteristics for 'external' code analysers. Ant pattern describing the path to SQALE characteristics, relative to projects root.

Example:


sonar.cxx.coverage.reportPath

Scope: project
Default: ---

Ant pattern describing the path of unit test coverage reports. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.coverage.itReportPath

Scope: project
Default: ---
History: no more supported with v0.9.9+ (or SQ6.2+)

Ant pattern describing the path of integration test coverage reports. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.coverage.overallReportPath

Scope: project
Default: ---
History: no more supported with v0.9.9+ (or SQ6.2+)

Ant pattern describing the path of overall test coverage reports. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.coverage.forceZeroCoverage

Scope: project
Default: True
History: no more supported with v0.9.9+ (or SQ6.2+)

If 'True', source files without coverage report results are set to zero coverage. This results in more realistic overall Technical Debt values. This setting is only enabled if one ore more of the keys sonar.cxx.coverage.reportPath, sonar.cxx.coverage.itReportPath or sonar.cxx.coverage.overallReportPath is defined (e.g. sonar.cxx.coverage.forceZeroCoverage and sonar.cxx.coverage.reportPath for line coverage). In case you have no report you have to assign a dummy report.

Example:


sonar.cxx.compiler.parser

Scope: project
Default: Visual C++
History: no more supported with v1.2.0+

The format of the warnings file. Currently supported are 'Visual C++' and 'GCC'.

Example:


sonar.cxx.compiler.reportPath

Scope: project
Default: ---
History: no more supported with v1.2.0+

Ant pattern describing the path to compiler output file. Path can be relative or absolute. Single path or comma separated list of paths is supported. The current default settings can be used for VC++ compiler log file. If available compiler macros and includes will be taken also from build log and used during the pre processing of sources. See Compilers

Example:


sonar.cxx.compiler.regex

Scope: project
Default: ^.*[\\\\,/](.*)\\(([0-9]+)\\)\\x20:\\x20warning\\x20(C\\d\\d\\d\\d):(.*)$
History: no more supported with v1.2.0+

Regular expression for four groups with this sequence:

  • file name
  • line number
  • message id
  • message text


*Example:*

sonar.cxx.compiler.charset

Scope: project
Default: UTF-16
History: no more supported with v1.2.0+

Charset used for the compiler log file (sonar.cxx.compiler.reportPath) e.g. UTF-8, UTF-16 (for more see java.nio.charset.Charset)

Example:


sonar.cxx.vc.reportPath

Scope: project
Default: ---

Ant pattern describing the path to compiler output file. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.vc.regex

Scope: project
Default: (.*>)?(?<file>.*)\\((?<line>\\d+)\\)\\x20:\\x20warning\\x20(?<id>C\\d+):(?<message>.*)

Regex must define the named groups <file>, <line>, <id>, <message>.



*Example:*

sonar.cxx.vc.charset

Scope: project
Default: UTF-8

Charset used for the compiler log file (sonar.cxx.vc.reportPath) e.g. UTF-8, UTF-16 (for more see java.nio.charset.Charset)

Example:


sonar.cxx.gcc.reportPath

Scope: project
Default: ---

Ant pattern describing the path to compiler output file. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Example:


sonar.cxx.gcc.regex

Scope: project
Default: (?<file>.*):(?<line>[0-9]+):[0-9]+:\\x20warning:\\x20(?<message>.*)\\x20\\[(?<id>.*)\\]

Regex must define the named groups <file>, <line>, <id>, <message>.

Example:


sonar.cxx.gcc.charset

Scope: project
Default: UTF-8

Charset used for the compiler log file (sonar.cxx.gcc.reportPath) e.g. UTF-8, UTF-16 (for more see java.nio.charset.Charset)

Example:


sonar.cxx.msbuild.reportPath

Scope: project
Default: ---

Ant pattern describing the path to MSBuild output file. Path can be relative or absolute. Single path or comma separated list of paths is supported. If available compiler macros and includes will be taken also from build log and used during the preprocessing of source files (see Compilers).

Example:


sonar.cxx.msbuild.charset

Scope: project
Default: UTF-8

Charset used for the MSBuild log file (sonar.cxx.msbuild.reportPath) e.g. UTF-8, UTF-16 (for more see java.nio.charset.Charset)

Example:


sonar.cxx.jsonCompilationDatabase

Scope: project
Default: ---

Enable CXX analysis to utilize JSON compilation database support. Specifies file to be used as JSON compilation database. JSON compilation database is used to improve C++ symbol and include directory knowledge. cxx plugin also supports extension to allow importing of used compiler's internal symbols and includes.

For more information please see: JSON compilation database format specification support

Example:


sonar.cxx.scanOnlySpecifiedSources

Scope: project
Default: False
History: no more supported with v1.0.0+

When using JSON compilation database support limit cxx plugin analysis to specified files in JSON compilation database. This setting can be used to limit analysis to only compiled files.

Example:


sonar.cxx.clangsa.reportPath

Scope: project
Default: ---

Ant pattern describing the path to Clang Static Analyzer plist reports. Path can be relative or absolute. Single path or comma separated list of paths is supported.

Examples:
sonar.cxx.clangsa.reportPath=divzero.plist
or
sonar.cxx.clangsa.reportPath=analyzer_reports/*/*.plist


sonar.cxx.funccomplexity.threshold

Scope: project
Default: 10

Cyclomatic complexity threshold used to classify a function as complex. The threshold is for the metrics:

  • Complex Functions: Number of functions with high cyclomatic complexity
  • Complex Functions (%): % of functions with high cyclomatic complexity
  • Complex Functions Lines of Code: Number of lines of code in functions with high cyclomatic complexity
  • Complex Functions Lines of Code (%): % of lines of code in functions with high cyclomatic complexity


sonar.cxx.funcsize.threshold

Scope: project
Default: 20

Function size threshold to consider a function to be too big. The threshold is for the metrics:

  • Big Functions: Number of functions with too many lines
  • Big Functions Lines of Code: Number of lines of code in functions with too many lines
  • Big Functions (%): Number of lines of code in functions with too many lines
  • Big Functions Lines of Code (%): % of lines of code in functions with too many lines


Hints V1.3.0:

  • no changes

Hints V1.2.1:

  • no changes

Hints V1.2.0:

  • GCC and MSVC compiler sensor can be used at the same time now
    • BREAKING CHANGE : sonar.cxx.compiler settings are no more supported!
      • use sonar.cxx.vc to read MSVC reports
      • use sonar.cxx.gcc to read GCC reports
      • use sonar.cxx.msbuild to read includes and defines from MSBuild log file
  • Setting sonar.cxx.missingIncludeWarnings is no more available. Turn debug info on to get information.
  • Usage of C plugin in parallel.
    • Please keep in mind that the C plugin is still experimental.
    • You can use all CXX configuration properties also for the C plugin: use sonar.c.xxx instead of sonar.cxx.xxx
    • You have to set specific (different) file extensions in sonar.cxx.suffixes.sources and sonar.c.suffixes.sources.
    • Set sonar.cxx.cFilesPatterns in the C plugin configuration (but not in the cxx plugin configuration).
  • Json compilation database support sonar.cxx.jsonCompilationDatabase is experimental only

Hints V1.1.0:

  • Usage of C plugin in parallel.
    • Please keep in mind that the C plugin is still experimental.
    • You can use all CXX configuration properties also for the C plugin: use sonar.c.xxx instead of sonar.cxx.xxx
    • You have to set specific file extensions in sonar.cxx.suffixes.sources and sonar.c.suffixes.sources.
    • sonar.cxx.cFilesPatterns should be set in the C plugin configuration but not in the cxx plugin configuration.
  • Json compilation database support sonar.cxx.jsonCompilationDatabase is also experimental only
    • sonar.cxx.scanOnlySpecifiedSources is no more supported. There were conflicts with sonar.sources and sonar.tests.
  • new configuration properties: sonar.cxx.funccomplexity.threshold and sonar.cxx.funcsize.threshold

Hints V1.0.0:

  • Usage of C plugin in parallel.
    • Please keep in mind that the C plugin is still experimental.
    • You can use all CXX configuration properties also for the C plugin: use sonar.c.xxx instead of sonar.cxx.xxx
    • You have to set specific file extensions in sonar.cxx.suffixes.sources and sonar.c.suffixes.sources.
    • sonar.cxx.cFilesPatterns should be set in the C plugin configuration but not in the cxx plugin configuration.
  • Json compilation database support sonar.cxx.jsonCompilationDatabase is also experimental only
    • sonar.cxx.scanOnlySpecifiedSources is no more supported. There were conflicts with sonar.sources and sonar.tests.

Hints V0.9.9:

  • There are some changes in the SQ core API, starting with SQ 6.2:
    • The property sonar.cxx.forceZeroCoverage is no more supported. There is now a SQ core support basing on EXECUTABLE_LINES_DATA.
  • sonar.cxx.coverage.itReportPath and sonar.cxx.coverage.overallReportPath are no more supported by the SQ core. There is no replacement available.
  • Usagage of C plugin in parallel.
    • Please keep in mind that the C plugin is still experimental.
    • You can use all CXX configuration properties also for the C plugin: use sonar.c.xxx instead of sonar.cxx.xxx
    • You have to set specific file extensions in sonar.cxx.suffixes.sources.
    • sonar.cxx.cFilesPatterns should be set in the C plugin configuration but not in the cxx plugin configuration.
  • Json compilation database support sonar.cxx.jsonCompilationDatabase is also experimental only.

Hints V0.9.8:

  • Clang Static Analyzer support v5.0.0 (plist reports) available: sonar.cxx.clangsa.reportPath.
  • Clang Tidy support available: sonar.cxx.clangtidy.reportPath.
  • CxxOtherSensor: XSLT pre-analyse support available:
    • sonar.cxx.other.N.inputs, sonar.cxx.other.N.outputs, sonar.cxx.other.N.stylesheet (N=1...9)
  • There are some changes in the SQ core API, starting with SQ 6.2:
    • The property sonar.cxx.forceZeroCoverage is no more supported. There is now a SQ core support basing on EXECUTABLE_LINES_DATA.
  • sonar.cxx.coverage.itReportPath and sonar.cxx.coverage.overallReportPath are no more supported by the SQ core. There is no replacement available.
  • Usagage of C plugin in parallel.
    • Please keep in mind that the C plugin is still experimental.
    • You can use all CXX configuration properties also for the C plugin: use sonar.c.xxx instead of sonar.cxx.xxx
    • You have to set specific file extensions in sonar.cxx.suffixes.sources.
    • sonar.cxx.cFilesPatterns should be set in the C plugin configuration but not in the cxx plugin configuration.
  • Json compilation database support sonar.cxx.jsonCompilationDatabase is also experimental only.

Hints V0.9.7:

  • Improved report handling: there is a tolerant and a strict mode now. In tolerant mode analysis continue in case of errors in a report file. In strict mode an error in a report file will stop the analysis (sonar.cxx.errorRecoveryEnabled). In versions before this one behaviour was sometimes strict and sometimes tolerant.
  • The default value of sonar.cxx.errorRecoveryEnabled is True now. To go back to old behaviour set the value to False.
  • sonar.cxx.forceZeroCoverage: better detection of executable lines. Resulting coverage can be slightly different.
  • Improved CPD algorithm with additional configuration settings sonar.cxx.cpd.ignoreLiterals and sonar.cxx.cpd.ignoreIdentifiers. To get same numbers as before set both to False.
  • sonar.cxx.xunit.provideDetailsis no more supported

Hints V0.9.6:

  • SQALE quality model is no more supported: sonar.cxx.other.sqales
  • support of new SonarQube Quality Model
  • support of Dr Memory reports: sonar.cxx.drmemory.reportPath
  • sonar.cxx.xunit.reportsPaths: XUnit over sonar-dotnet-tests-library is supported now

Hints V0.9.5:

  • sonar.cxx.vstest.reportsPaths: TRX output from VSTest is supported now
  • sonar.cxx.nunit.reportsPaths: XML output from the NUnit console runner is supported now
  • reportPath: path can be relative or absolute now. Paths inside and outside of root folder are supported.
  • reportPath: Single path or comma separated list of paths is supported.
  • Support of placeholder in configuration file. Format is ${xxx}, supported are environment variables, Java system properties and SonarQube properties.

Hints V0.9.4:

  • Default values for reportPath values has been removed to get meaningful error messages. In case you were using the defaults you have to explicit define them in the sonar-project.properties file now.
  • forceZeroCoverage: Depends on which key (sonar.cxx.coverage.reportPath, sonar.cxx.coverage.itReportPath, sonar.cxx.coverage.overallReportPath) is defined in the sonar-project.properties file now. Defining forceZeroCoverage alone will no more work.
  • EXPERIMENTAL: It is now possible to define SQALE characteristics for external rules (other) sonar.cxx.other.sqales.

Hints V0.9.3:

  • Starting with this version it is possible to automatically retrieve includes, defines and compiler options from a Visual Studio log file. Create the log file with the option /v:Diagnostic and assign it to sonar.cxx.compiler.reportPath.

Hints V0.9.2:

  • New property sonar.cxx.coverage.forceZeroCoverage set coverage for source files without coverage report to 0. For V0.9.1 compatibility set value to 'false'.
  • New property sonar.cxx.xunit.provideDetails. To get detailed unit test information set property to 'true'. This is also the V0.9.1 compatibility value. Because SonarQube does not support 'virtual files' any more test resources must be available.
  • new property sonar.cxx.cFilesPatterns

Hints V0.9.1:

  • Configuration setting sonar.cxx.cppncss.reportPath is no longer supported.
  • Rename configuration setting sonar.cxx.externalrules.reportPath to sonar.cxx.other.reportPath
  • Rename configuration setting sonar.cxx.include_directories to sonar.cxx.includeDirectories
  • new property sonar.cxx.forceIncludes

Hints V0.9.0:

  • Use sonar.cxx.include_directories instead of sonar.cxx.includeDirectories
Clone this wiki locally