Affects Version/s: current
Fix Version/s: None
Using the lastest cppcheck (v1.1). cppcheck is unable to produce linkable references to the source code when Subversion is used to check out the code.
If you have a project that uses SVN, by default it is checked out into a sub directory under the Jenkins workspace named as the last part of the Subversion URL. This is document in Jenkins in the "If left empty" portion of the optional module local directory:
"Specify a local directory (relative to the workspace root) where this module is checked out. If left empty, the last path component of the URL is used as the default, just like the svn CLI. A single period (.) may be used to check out the project directly into the workspace rather than into a subdirectory."
So we have a project with a Subversion URL:
As a result, our Jenkins workspace becomes:
and the source code is checked out in:
cppcheck is run from the Jenkins workspace:
and the cppcheck-results.xml file ends up in the Jenkins workspace:
But, the cppcheck reporter is not using the Jenkins workspace as the root for references in cppcheck-results.xml (/build/workspace/myproj_P2_0_0_cppcheck). The cppcheck reporter is using the SVN check out location to generate the report (/build/workspace/myproj_P2_0_0_cppcheck/myproj).
Here is an entry from the cppcheck-results.xml file:
<error file="/myproj/ADI Sharc/Shared/EDFA/deviceClass.c" id="s_tempStorageAssignment" line="34" msg="Implicitly only sto
rage pObj->pOutVar (type ST_ADC_POINT_T *) not released before assignment: pObj->pOutVar = pOutObj A memory leak h
as been detected. Only-qualified storage is not released before the last reference to it is lost. (Use -mustfreeonly to
inhibit warning)" severity="warning"/>
And the cppcheck plugin generates the following warning:
[Cppcheck] [WARNING] - The source file 'file:/build/workspace/myproj_P2_0_0_cppcheck/myproj/myproj/ADI%20Sharc/Shared/EDFA/deviceClass.c' doesn't exist on the slave. The ability to display its source code has been removed.
Note the duplication of the myproj directory. The reporter is not using the Jenkins workspace as the root directory. It is using the SVN check out directory. The report generation should be built relative to the Jenkins workspace, not to the SVN check out directory.
This should be easy to fix. The reporter should be using the present working directory of the cppcheck-result.xml file as the path to prepend to the file spec from the cppcheck-results.xml file.
For example, in this case, the reporter start up to examin the cppcheck-results.xml file:
File in cppcheck-results.xml message:
File path is:
pwd + cppcheck-results.xml file = /build/workspace/myproj_P2_0_0_cppcheck/myproj/ADI Sharc/Shared/EDFA/deviceClass.c