-
Notifications
You must be signed in to change notification settings - Fork 364
sonar.cxx.pclint.reportPaths
guwirth edited this page Mar 10, 2021
·
10 revisions
Sensor to read reports from the PC-lint tool. PC-lint Plus is a comprehensive static analysis solution for C and C++. PC-lint Plus can check for violations of internal code guidelines as well as analyzing compliance with industry standards such as MISRA, AUTOSAR, and CERT C.
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!
- Link to the tool page: https://gimpel.com/
- The sensor supports rules from PC-lint with version 9.0.
In order to run PC-lint 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 insonar-project.properties
- The PC-lint XML output needs to be formatted:
// XML options for cxx plugin.
-v // Turn off verbosity
-width(0,0) // Don't break long lines
+xml(?xml version="1.0" ?) // add version information
+xml(results) // Turn on XML escapes
-"format=<issue file =\q%f\q line = \q%l\q number = \q%n\q type=\q%t\q desc = \q%m\q/>"
-"format_specific= "
-hFs1 // The height of a message should be 1 i.e. don't output the line in error
-e900 // 'Successful completion message'
Sample command lines:
lint-nt.exe <args>... <files>...
If the tool was executed successfully, a report like the example below should be generated:
<?xml version="1.0" encoding="UTF-8"?>
<result>
<issue file =".\test.c" line = "4" number = "1960" desc = "Violates MISRA C++ 2008 Required Rule 5-0-19, More than two pointer indirection levels used for type: 'struct _wireSAFEARRAY ***"/>
<issue file =".\test.c" line = "10" number = "586" desc = "operator 'new' is deprecated. [MISRA C++ Rule 18-4-1]"/>
</result>
- First check if the file extensions read in by the cxx plugin are set (sonar.cxx.file.suffixes).
- 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.
- Set the analysis parameter
sonar.cxx.pclint.reportPaths
in the configuration filesonar-project.properties
of your project. The Report Paths link describes the configuration options. - Execute the SonarScanner to transfer the project with the report to the SonarQube Server.
Sample for sonar-project.properties:
sonar.cxx.pclint.reportPaths=pclint.xml
- If scanning is failing, check items listed under Troubleshooting Configuration.
- If no issues are displayed for your source code in SonarQube, check the items listed under Troubleshooting Reports.
- In the case of incomplete scans, Detect and fix parsing errors gives advice on how to fix this.