sonar-rules-extractor is a Python tool that extracts the violation rules from analysis tools like Cppcheck, C++Test, Klocwork, etc. and converts them into Sonar rules.
Why converting those rules into Sonar rules?
When we are doing a conformity analysis of coding rules, the output of this analysis gives us a link between the line of the source file where the rule has been violated and the ID of this violated rule. An association between a rule ID and its description has to be given to Sonar.
To take into account all the custom rules developed in the quality analysis tools, it is necessary to have a utility which exports those tools' rules. The Sonar Rules Extractor is there for that.
Note: Sonar has by default five kinds of rule severity: Blocker, Critical, Major, Minor, Info. But it is not the case for all the analysis tools. For example, in Klocwork, the severities are represented by numbers : 1 (Critical) to 10 (Info).
The Sonar Rules Extractor will have a mapping of those levels so they mean something to Sonar.
How to install it?
If you have Python setuptools already installed and have a direct internet connection, you just need to run the following command:
root@localhost:~# easy_install -O2 sonar-rules-extractor
If Python setuptools is not installed, please install it first.
If you don't have a direct connection to the internet, download a package suitable to your distribution and install it.
root@localhost:~# tar zxvf sonar-rules-extractor*.tar.gz
root@localhost:~# cd sonar-rules-extractor*
root@localhost:~# python setup.py install -O2
For windows users who don't want to run the command line installer, there is a native .exe package.