Skip to content

CXX Analysis Parameters

Günter Wirth edited this page Nov 15, 2024 · 15 revisions

The general Analysis Parameters are described in the SonarQube documentation. There is also the information where these can be set. This page describes the additional configuration parameters of the cxx plugin.

In principle, a distinction can be made between parameters for the configuration of the CXX language (see Scan Source Code) and the sensors for reading in reports. The report sensors can also be used together with the SonarCFamily plugin.

CXX Language

Mandatory Parameters

key description
sonar.cxx.file.suffixes Comma-separated list of suffixes for files to analyze (e.g. .cxx,.cpp,.cc,.c,.hxx,.hpp,.hh,.h). In the SonarQube UI, enter the file suffixes into the fields one by one. To turn off the CXX language, set the first entry to -.
sonar.cxx.errorRecoveryEnabled Defines the mode for error handling of report files and parsing errors. False (strict) terminates after an error or True (tolerant) continues.

Squid Sensor

key description
sonar.cxx.squid.disabled Disable parsing of source code, syntax highlighting and metric generation. The source files are still indexed, reports can be read and their results displayed. Turning off will speed up reading of source files.

Preprocessor Parameters

key description
sonar.cxx.defines List of macros to be used by the preprocessor during analysis. Enter one macro per line. The syntax is the same as #define directives, except for the #define keyword itself.
sonar.cxx.includeDirectories Comma-separated list of directories where the preprocessor looks for include files. The path may be either absolute or relative to the project base directory.
sonar.cxx.forceIncludes Comma-separated list of include files implicitly inserted at the beginning of each source file. This has the same effect as specifying the file with double quotation marks in an #include directive on the first line of every source file. If you add multiple files they are included in the order they are listed from left to right. The path may be either absolute or relative to the project base directory.
sonar.cxx.jsonCompilationDatabase Read a JSON Compilation Database file to automatically extract the required macros sonar.cxx.defines and include directories sonar.cxx.includeDirectories from a file. The path may be either absolute or relative to the project base directory.
sonar.cxx.jsonCompilationDatabase. analyzeOnlyContainedFiles Defines the mode for sonar.cxx.jsonCompilationDatabase. If sonar.cxx.jsonCompilationDatabase.analyzeOnlyContainedFiles = True is used, the analyzed files will be limited to the files contained in the 'JSON Compilation Database' file - the intersection of the files configured via sonar.projectBaseDir and the files contained in the 'JSON Compilation Database' file (default is False).
sonar.cxx.msbuild.encoding Defines the encoding to be used to read the files from sonar.cxx.msbuild.reportPaths (default is UTF-8).
sonar.cxx.msbuild.reportPaths Read one ore more MSBuild .LOG files to automatically extract the required macros sonar.cxx.defines and include directories sonar.cxx.includeDirectories. The path may be either absolute or relative to the project base directory.

CXX Metrics

key description
sonar.cxx.metric.api.file.suffixes Comma-separated list of suffixes for files to be searched for API comments and to create API metrics.
sonar.cxx.metric.cpd.ignoreIdentifiers Configure the metrics Duplications (Copy Paste Detection). True ignores identifier value differences when evaluating a duplicate block e.g. variable names, methods names, and so forth.
sonar.cxx.metric.cpd.ignoreLiterals Configure the metrics Duplications (Copy Paste Detection). True ignores literal (numbers, characters and strings) value differences when evaluating a duplicate block. This means that e.g. foo=42; and foo=43; will be seen as equivalent.
sonar.cxx.metric.func.complexity.threshold The parameter defines the threshold for Complex Functions .... Functions and methods with a higher cyclomatic complexity are classified as complex.
sonar.cxx.metric.func.size.threshold The parameter defines the threshold for Big Functions .... Functions and methods with more lines of code are classified as big.

CXX Report Sensors

XLS Transformation (execution before other sensors)

key description
sonar.cxx.xslt built-in XLS transformation

Test

key description
sonar.cxx.nunit.reportPaths Paths to NUnit execution reports. Multiple paths may be comma-delimited, or included via wildcards. Note that while measures such as the number of tests are displayed at project level, no drilldown is available.
sonar.cxx.vstest.reportPaths Paths to VSTest reports. Multiple paths may be comma-delimited, or included via wildcards. Note that while measures such as the number of tests are displayed at project level, no drilldown is available.
sonar.cxx.xunit.reportPaths Comma-separated list of paths to the various directories containing the *.xml xUnit report files. Each path may be absolute or relative to the project base directory. Ant patterns are accepted for relative paths. Note that while measures such as the number of tests are displayed at project level, no drilldown is available.
sonar.testExecutionReportPaths Generic test execution report format: SonarQube supports a generic format for test execution import. If the native output of your tool is not supported by SonarQube, you must convert it to this format.

Coverage

key description
sonar.cxx.bullseye.reportPaths Comma-separated list of paths pointing to coverage reports (absolute or relative to the project base directory). Ant patterns are accepted for relative path. The reports have to conform to the BullseyeCoverage XML format.
sonar.cxx.cobertura.reportPaths Comma-separated list of paths pointing to coverage reports (absolute or relative to the project base directory). Ant patterns are accepted for relative path. The reports have to conform to the Cobertura XML format.
This sensor supports also gcov/gcovr coverage reports --xml and OpenCppCoverage --export_type=cobertura.
sonar.cxx.ctctxt.encoding Defines the encoding to be used to read the files from sonar.cxx.ctctxt.reportPaths (default is UTF-8).
sonar.cxx.ctctxt.reportPaths Comma-separated list of paths pointing to coverage reports (absolute or relative to the project base directory). Ant patterns are accepted for relative path. The reports have to conform to the Testwell CTC++ textural format.
sonar.cxx.vscoveragexml.reportPaths Comma-separated list of paths pointing to coverage reports (absolute or relative to the project base directory). Ant patterns are accepted for relative path. The reports have to conform to the Visual Studio Coverage XML format.
sonar.coverageReportPaths Generic test coverage report format: SonarQube supports a generic format for test coverage import. If the native output of your coverage tool is not supported by SonarQube, you must convert it to this format.

Compiler

key description
sonar.cxx.gcc.encoding Defines the encoding to be used to read the files from sonar.cxx.gcc.reportPaths (default is UTF-8).
sonar.cxx.gcc.regex Java regular expressions to parse the GCC warnings. You can use the named-capturing groups <file>, <line>, <column>, <id> and <message>.
sonar.cxx.gcc.reportPaths Comma-separated paths (absolute or relative to the project base directory) to *.log files with GCC warnings. Ant patterns are accepted for relative paths.
sonar.cxx.vc.encoding Defines the encoding to be used to read the files from sonar.cxx.vc.reportPaths (default is UTF-8).
sonar.cxx.vc.regex Java regular expressions to parse the Visual Studio warnings. You can use the named-capturing groups <file>, <line>, <column>, <id> and <message>.
sonar.cxx.vc.reportPaths Comma-separated paths (absolute or relative to the project base directory) to *.log files with Visual Studio warnings. Ant patterns are accepted for relative paths.

Tools

key description
sonar.cxx.clangsa.reportPaths Comma-separated paths (absolute or relative to the project base directory) to *.plist files with Clang Static Analyzer issues. Ant patterns are accepted for relative paths.
sonar.cxx.clangtidy.encoding Defines the encoding to be used to read the files from sonar.cxx.clangtidy.reportPaths (default is UTF-8).
sonar.cxx.clangtidy.reportPaths Comma-separated paths (absolute or relative to the project base directory) to *.txt files with Clang-Tidy issues. Ant patterns are accepted for relative paths.
sonar.cxx.cppcheck.reportPaths Comma-separated paths (absolute or relative to the project base directory) to *xml files with Cppcheck issues. Ant patterns are accepted for relative paths.
sonar.cxx.drmemory.encoding Defines the encoding to be used to read the files from sonar.cxx.drmemory.reportPaths (default is UTF-8).
sonar.cxx.drmemory.reportPaths Comma-separated paths (absolute or relative to the project base directory) to *.txt files with Dr. Memory issues. Ant patterns are accepted for relative paths.
sonar.cxx.infer.reportPaths Comma-separated paths (absolute or relative to the project base directory) to *.json files with Infer issues. Ant patterns are accepted for relative paths.
sonar.cxx.pclint.reportPaths Comma-separated paths (absolute or relative to the project base directory) to *.xml files with PC-lint issues. Ant patterns are accepted for relative paths.
sonar.cxx.rats.reportPaths Comma-separated paths (absolute or relative to the project base directory) to *.xml files with RATS issues. Ant patterns are accepted for relative paths.
sonar.cxx.valgrind.reportPaths Comma-separated paths (absolute or relative to the project base directory) to *.xml files with Valgrind issues. Ant patterns are accepted for relative paths.
sonar.cxx.vera.reportPaths Comma-separated paths (absolute or relative to the project base directory) to *.xml files with Vera++ issues. Ant patterns are accepted for relative paths.

Generic issues

key description
sonar.externalIssuesReportPaths Generic issue import format: SonarQube supports a generic import format for raising external issues in code. You can use this format to import issues from your favorite linter even if there's no plugin for it.
sonar.sarifReportPaths Importing issues from SARIF reports: SonarQube supports the standard Static Analysis Results Interchange Format (SARIF) for raising external issues in code.
sonar.cxx.other.reportPaths CXX plugin specific generic issue import format: Comma-separated paths (absolute or relative to the project base directory) to *.xml files with other issues. Ant patterns are accepted for relative paths.
sonar.cxx.other.rules CXX plugin specific XML rule definitions for other code analyzers. Use a separate field for each tool.
Clone this wiki locally