...
Cxx plugin uses the following properties during analysis. See here for the ways how to pass them to the plugin.
Property | Scope | Default | Example | Description |
|---|---|---|---|---|
| sonar.cxx.suffixes.sources | System- and/or project-wide | cxx,cpp,cc,c | .C,.h | Comma separated list of file name extension to be considered as C++ source files during analysis. Leave unset to use the default ("cxx,cpp,cc,c") |
| sonar.cxx.suffixes.headers | System- and/or project-wide | hxx,hpp,hh,h | Comma separated list of file name extension to be considered as C++ source files during analysis. Leave unset to use the default ("hxx,hpp,hh,h") | |
| sonar.cxx.cppcheck.reportPath | Project-wide | cppcheck-reports/cppcheck-result-*.xml | cppcheck-report-*.xml | Ant pattern describing the path to Cppcheck reports, relative to projects root. Leave unset to use the default ("cppcheck-reports/cppcheck-result-*.xml"). |
| sonar.cxx.cppncss.reportPath | Project-wide | cppncss-reports/cppncss-result-*.xml | cppncss-report-*.xml | Ant pattern describing the path to CppNcss reports, relative to projects root. Leave unset to use the default ("cppncss-reports/cppncss-result-*.xml"). |
| sonar.cxx.gcovr.reportPath (<0.2) | Project-wide | gcovr-reports/gcovr-result-*.xml | gcovr-report-*.xml | Ant pattern describing the path to gcovr reports, relative to projects root. Leave unset to use the default ("gcovr-reports/gcovr-result-*.xml"). |
| sonar.cxx.rats.reportPath | Project-wide | rats-reports/rats-result-*.xml | rats-report-*.xml | Ant pattern describing the path to RATS reports, relative to projects root. Leave unset to use the default ("rats-reports/rats-result-*.xml"). |
| sonar.cxx.valgrind.reportPath | Project-wide | valgrind-reports/valgrind-result-*.xml | valgrind-report-*.xml | Ant pattern describing the path to Valgrind reports, relative to projects root. Leave unset to use the default ("valgrind-reports/valgrind-result-*.xml"). |
| sonar.cxx.vera.reportPath | Project-wide | vera++-reports/vera++-result-*.xml | vera-report-*.xml | Ant pattern describing the path to Vera++ reports, relative to projects root. Leave unset to use the default ("vera++-reports/vera++-result-*.xml"). |
| sonar.cxx.xunit.reportPath | Project-wide | xunit-reports/xunit-result-*.xml | xunit-report-*.xml | Ant pattern describing the path to unit test execution reports, relative to projects root. Leave unset to use the default ("xunit-reports/xunit |
| sonar.cxx.externalrules.reportPath | Project-wide | externalrules-result/externalrules-result-*.xml"). | externalrules-result-*.xml | Ant pattern describing the path to unit test execution reports, relative to projects root. |
| sonar.cxx.xunit.xsltURL | Project-wide | cppunit-1.x-to-junit-1.0.xsl | A name of a built in XSLT-file or an URL to an external one. Available builtins:
Leave unset if no transformation should be used. | |
| sonar.cxx.coverage.reportPath (>=0.2) | Project-wide | coverage-reports/coverage-*.xml | coverage-*.xml | Ant pattern describing the path of unit test coverage reports, relative to projects root. Leave unset to use the default ("coverage-reports/coverage-*.xml"). |
| sonar.cxx.coverage.itReportPath (>=0.2) | Project-wide | coverage-reports/it-coverage-*.xml | it-coverage-*.xml | Ant pattern describing the path of integration test coverage reports, relative to projects root.Leave unset to use the default (" |
| sonar.cxx.coverage.itReportPath (>=0.2) | Project-wide | coverage-reports/itoverall-coverage-*.xml"). |
...
| overall-coverage-*.xml | Ant pattern describing the path of integration test coverage reports, relative to projects root. |
Note: Report paths are always relative to projects path.
Usage
You can analyze your projects using the usual means (see this page for all available). All runners should work. See below for details how to do it for maven-, ant-, and all-the-other-projects.
...
| Code Block |
|---|
rats -w 3 --xml <sources> > report.xml |
PC-Lint
Todo
External Rules
Import of violations
As of version 0.2, any static analysis tool can be reused with the plugin using the property sonar.cxx.externalrules.reportPath. The following table describes the format of the report
| Xml Description - RNG-Schema | Example |
|---|---|
<element name="results" xmlns="http://relaxng.org/ns/structure/1.0"> <zeroOrMore> <element name="error"> <attribute name="file"/> <attribute name="msg"/> <attribute name="id"/> <attribute name="line"> <data type="integer" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes" /> </attribute> <text/> </element> </zeroOrMore> </element> | <?xml version="1.0"?> |
| Attribute | Description |
| file | source file, relative to project path |
| line | line of the violation |
| id | id of the rule, mapped a rule in sonar. See "Enable the rules in Sonar server" below |
| msg | description of the violation |
Enable the rules in Sonar server
To reuse reports from other tools the C++ quality profile in sonar needs to be inline with the reported violations in the external report.
Known limitations
- Some analyzers (RATS, most notably) may have issues and crash occasionally.
- Valgrind is only available on a subset of UNIX platforms.
...

