Boost Code Quality with the standalone CppDepend's SonarQube Extension.

Enhance Your C/C++ Development with CppDepend's SonarQube Plugin

IMPORTANT:

This documentation pertains to the complete C/C++ SonarQube integration, eliminating the need to install any SonarQube C++ plugins for source code parsing. If you are using a different C/C++ SonarQube plugin and only wish to import CppDepend issues, please consult the documentation for the SonarQube Light Integration.

To operate CppDepend on a machine, you must first activate your professional DevOps license or evaluation period. Once the CppDepend files are unzipped on the machine, run VisualCppDepend.exe once. If the machine is connected to the internet, a brief activation process will occur.

If the machine is offline, an alternative offline activation procedure will be provided, which must be completed to use the SonarQube CppDepend plugin.

The CppDepend SonarQube plugin is compatible with SonarQube version 5.6 and above.

C/C++ Plugin Prerequisites

  • Install SonarQube.
  • Install SonarQube Scanner or the old Sonar Runner.
  • Add the SonarQube Scanner or the SonarRunner bin directory to the PATH environment variable.

Plugin installation and configuration

  • Copy the sonar-cxx-cppdepend-standalone-plugin-1.0 from $CppDependInstallDir$/Integrations/SonarQube to the $SonarQubeInstallDir$\extensions\plugins directory and restart SonarQube.
  • The default CppDepend rules are loaded to the SonarQube rules repository. However, if you need to customize these rules you can define your own custom rules using the .cdproj file path located under the SonarQube Administration Tab.

    CppDepend rules in SonarQube
  • You have to log in as an admin and activate the CppDepend rules in the profile you want.

    Activating the CppDepend rules
  • Run Sonar-Scanner

  • Here is the SonarQube documentation concerning runnig Sonar-Scanner from the command line argument.

    The cppdepend project file parameter is mandatory -D sonar.cpp.cppdepend.projectPath={the path of cdproj}.

    The cppdepend scanner executable parameter is mandatory -Dsonar.cppdepend.scanner=$CppDependInstallDir/Libs/CppDepend.SonarQubeScanner.exe.


    On Windows:
    >sonar-scanner  -Dsonar.cpp.cppdepend.projectPath={the path of cdproj} -Dsonar.cppdepend.scanner="$CppDependInstallDir/Libs/CppDepend.SonarQubeScanner.exe"
        

    On Linux/MacOS:
    >sonar-scanner  -Dsonar.cpp.cppdepend.projectPath={the path of cdproj} -Dsonar.cppdepend.scanner="$CppDependInstallDir/libs/CppDepend.SonarQubeScanner"
        

    Don't use any environment variable in paths and if the path contains a space character, surround it with double quotes -D sonar.cpp.cppdepend.projectPath="C:\work with space\project.cdproj"

Plugin features

  • Multi Module analysis: a CppDepend project could contain many C/C++ projects.
    After the analysis, CppDepend does not put all the code in the same SonarQube module. However, it creates a multi module sonarqube project to isolate each project into a separate module which makes the code navigation very easy.

    Multi Module sonarqube analysis

  • Issues: CppDepend provides by default more than 250 rules, which you can easily customize completely.
    CppDepend provides a powerful way to compute the technical debt of the issues. The CppDepend technical debt and the issue severity are given to SonarQube.

    CppDepend issues in SonarQube
  • Standard metrics: the plugin calculates all the standard SonarQube metrics.

    Standard Metrics in SonarQube
  • Code duplication: The duplications are detected by the CPD tool embedded in SonarQube.

    Code Duplication in SonarQube
  • Coverage: The plugin loads the coverage result from Cobertura and Microsoft Visual Studio XML result files.
    However, you have to set the path where the xml coverage files exist.
    Code Coverage Configuration

    Code Coverage in SonarQube

CppDepend offers a wide range of features. It is often described as a Swiss Army Knife for C and C++ developers.

Start Free Trial