CppDepend SonarQube Light Integration

SonarQube community edition Integration

  • This documentation concerns the light C/C++ SonarQube integration. In this case you need to install a SonarQube C++ plugin to parse your source code.
    In case you want a full C/C++ SonarQube plugin, please refer to the documentation of the full SonaQube integration.
  • To run CppDepend on a machine you need first to activate your pro BuildMachine licensing or your evaluation period.

    To do so, once CppDepend files unzipped on the machine, just run once VisualCppDepend.exe. You'll go through a few seconds activation procedure if the machine is connected to internet.

    If the machine is not connected to internet, an offline activation procedure will be proposed instead, and must be fulfilled in order to run the SonarQube CppDepend plugin.
  • The CppDepend SonarQube plugin supports SonarQube version 5.6 and higher.

Plugin Prerequisites

Install the CppDepend Plugin

    Copy the sonar-cxx-cppdepend-lightplugin-VERSION.jar

    • from the $CppDependInstallDir$\SonarPlugin directory
    • to the $SonarQubeInstallDir$\extensions\plugins directory
    • Restart the SonarQube server for it to take account of the CppDepend plugin.


If you are not using the CppDepend plugin on SonarQube install, make sure to remove its sonar-cxx-cppdepend-lightplugin-VERSION.jar file from the $SonarQubeInstallDir$\extensions\plugins directory and then restart the SonarQube server.
Else the CppDepend plugin will check for certain pathes and parameters, and if not found, it will break the SonarQube analysis with an error.

Define the CppDepend Rules-set that will be configured into the Sonar server
  • In the SonarQube user interface, go to Administration. You need to be logged with the appropriate administrator privileges for that.

  • MANDATORY Specify the path to CppDepend.SonarQube.RuleRunner.exe. This path is $CppDependInstallPath$\SonarPlugin\CppDepend.SonarQube.RuleRunner.exe. Don't prefix the path with an environnement variable path, write the entire absolute path (follow this advice for all paths writing you'll find in this documentation).
  • OPTIONAL Specify the CppDepend project file path (.cdproj extension) to fetch the rules from. If it's not specified the default CppDepend rule set will be used.
    If you specify the CppDepend project file path, the rules taken account are activated rules defined in:
    • The CppDepend project file,
    • Rules defined in the CppDepend Rules Files referenced by the CppDepend project file

Activate the CppDepend Rules in the Sonar server

The CppDepend rules are now loaded in the SonarQube repository but not activated yet.
To activate them, you have to:

  • Log as admin in the SonarQube UI:
  • Go to the Rules tab:
  • Choose Language C++ and Repository: CppDepend

  • Activate these rules in the profile you want by clicking on Bulk Change - Activate In:

  • Notice that the handle of a rule is the rule name with also the parent group(s) names and the rule source code. This remark is important in this situation when:
    - The NDepend project used for analysis contains a custom rule-set
    - The NDepend project specified in the SonarQube configuration to define the rules in the SonarQube system (parameter CppDepend rules from ndproj, see the previous section) is different from the NDepend project used for analysis.

    In such situation if the two rules-set don't correspond exactly, the rules won't be resolved in the SonarQube system and the issues won't be computed.
  • If some rules have been added or removed in your custom rule-set:
    1) Restart the SonarQube server to let it parse the NDepend project specified in the SonarQube configuration to define the rules
    2) go again in the Rules tab logged as administrator, to activate/deactivate these new/removed rules through eventually a Bulk Change action.

Run Sonar-Scanner

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

To let the SonarQube Scanner also runs CppDepend analysis and rules, you need to append the mandatory parameter -D sonar.cpp.cppdepend.projectPath={the path of cdproj}.
By default the plugin load the latest analysis result done for the cdproj. And not launch the analysis of the project by CppDepend. In this case an anlysis must be done by CppDepend first.

If you want to launch the cppdepend analysis from the plugin the -D sonar.cpp.cppdepend.runAnalysis=true is required

Command without the CppDepend analysis from the plugin, In this case we will use an existing analyzed result:
>sonar-scanner  -D sonar.cpp.cppdepend.projectPath={the path of cdproj}

Command with the CppDepend analysis from the plugin:
>sonar-scanner  -D sonar.cpp.cppdepend.projectPath={the path of cdproj} -D  sonar.cpp.cppdepend.runAnalysis=true

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"

Browse CppDepend Rules Issues in the SonarQube UI

    CppDepend Rules Issues are now reported as any issues in the SonarQube UI.

    You can browse it, go to source code declaration (in the UI), assign it, change its status...

  • If some issues are missing in the SonarQube UI:
    - Check that you followed all rules activation steps explained in this document.
    - Then double check that the concerned rule is indeed activated by checking if it emits at least one issue.
    - In such case, if some issues are missing, this is because the source file declaration of their parent types hasen't been found. Typically this happens with types and their members generated by the compiler.

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

Start Free Trial