Skip to content

sonar.cxx.vera.reportPaths

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

Overview

Sensor to read reports from the Vera++ tool. Vera++ is a programmable tool for verification, analysis and transformation of C++ source code. Vera++ is mainly an engine that parses C++ source files and presents the result of this parsing to scripts in the form of various collections - the scripts are actually performing the requested tasks.

Note: The cxx plugin itself does not run the tool, you have to do that yourself beforehand. The sensor only reads the report generated by the tool!

Supported versions

Create report

In order to run Vera++ and generate a fitting report, make sure:

  • to call it from the projects root directory, so that the paths in the report fit
  • that the parameter matches the sonar.sources list in sonar-project.properties

Sample command lines:

Newer versions of Vera++ support the -c / --checkstyle-report command line option to create a Checkstyle XML report:

vera++ -s -c vera.xml main.cxx

Example of a report file

If the tool was executed successfully, a report like the example below should be generated:

<?xml version="1.0" encoding="UTF-8"?>
<checkstyle version="5.0">
    <file name="sources/application/main.cpp">
        <error line="1" severity="warning" message="no copyright notice found" source="T013"/>
    </file>
    <file name="sources/utils/utils.cpp">
        <error line="1" severity="warning" message="leading empty line(s)" source="L003"/>
        <error line="1" severity="warning" message="no copyright notice found" source="T013"/>
    </file>
</checkstyle>

Configure cxx plugin

  1. First check if the file extensions read in by the cxx plugin are set (sonar.cxx.file.suffixes).
  2. The rules for which you want to generate issue must be activated in the Quality Profile of your project. You can find instructions on how to do this under Manage Quality Profiles.
  3. Set the analysis parameter sonar.cxx.vera.reportPaths in the configuration file sonar-project.properties of your project. The Report Paths link describes the configuration options.
  4. Execute the SonarScanner to transfer the project with the report to the SonarQube Server.
  5. With CXX Custom Template Rules it's possible to extend the rule repository.
  6. It is also possible to display unknown rules on the SonarQube Server.

Sample for sonar-project.properties:

sonar.cxx.vera.reportPaths=vera.xml

Troubleshooting

Clone this wiki locally