{"action":"created","issue":{"url":"https://api.github.com/repos/wenns/sonar-cxx/issues/426","labels_url":"https://api.github.com/repos/wenns/sonar-cxx/issues/426/labels{/name}","comments_url":"https://api.github.com/repos/wenns/sonar-cxx/issues/426/comments","events_url":"https://api.github.com/repos/wenns/sonar-cxx/issues/426/events","html_url":"https://github.com/wenns/sonar-cxx/issues/426","id":57670567,"number":426,"title":"Relative paths in Cobertura reports are treated relative to the current directory instead of the projectBaseDir","user":{"login":"abbeyj","id":99402,"avatar_url":"https://avatars.githubusercontent.com/u/99402?v=3","gravatar_id":"","url":"https://api.github.com/users/abbeyj","html_url":"https://github.com/abbeyj","followers_url":"https://api.github.com/users/abbeyj/followers","following_url":"https://api.github.com/users/abbeyj/following{/other_user}","gists_url":"https://api.github.com/users/abbeyj/gists{/gist_id}","starred_url":"https://api.github.com/users/abbeyj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/abbeyj/subscriptions","organizations_url":"https://api.github.com/users/abbeyj/orgs","repos_url":"https://api.github.com/users/abbeyj/repos","events_url":"https://api.github.com/users/abbeyj/events{/privacy}","received_events_url":"https://api.github.com/users/abbeyj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-14T00:02:24Z","updated_at":"2015-02-14T07:11:43Z","closed_at":null,"body":"When using reports in Cobertura format that contain relative paths and running sonar-runner from a directory other than the projectBaseDir, the paths are canonicalized incorrectly.  This leads to the relevant files not being found.\r\n\r\nFor instance, say my project base directory is ./base_dir and I also have ./sonar/sonar-project.properties.  After building the project, I switch to the ./sonar directory and then run sonar-runner.  The current directory while running is ./sonar but relative paths in the Cobertura report should be taken relative to the projectBaseDir.  Making them relative to the current directory isn't going to find anything as the only thing in the sonar directory is the sonar-project.properties file.\r\n\r\nI have sample project to demonstrate this at http://files.stardrifter.org/pub/cobertura_paths.tar.gz\r\n\r\nTo use it:\r\n$ tar xzvf cobertura_paths.tar.gz\r\n$ cd cobertura_paths/base_dir\r\n$ make\r\n$ cd ../sonar\r\n$ sonar-runner\r\n\r\nYou'll see a message like\r\nWARN  - Cannot find the file '&lt;snip&gt;/cobertura_paths/**sonar**/main.cpp', ignoring coverage measures\r\n\r\nIt should be looking instead for .../cobertura_paths/**base_dir**/main.cpp which is where the file is actually located.\r\n\r\nI believe the problem occurs at the normalizePath call here:\r\nhttps://github.com/wenns/sonar-cxx/blob/79894beea01bd829275c8c6e5502855bcf063cb1/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CoberturaParser.java#L70\r\n\r\nThis needs to be modified to take into account the projectBaseDir from the .properties file and not just use the current directory as CxxUtils.normalizePath does.\r\n"},"comment":{"url":"https://api.github.com/repos/wenns/sonar-cxx/issues/comments/74365115","html_url":"https://github.com/wenns/sonar-cxx/issues/426#issuecomment-74365115","issue_url":"https://api.github.com/repos/wenns/sonar-cxx/issues/426","id":74365115,"user":{"login":"guwirth","id":6077367,"avatar_url":"https://avatars.githubusercontent.com/u/6077367?v=3","gravatar_id":"","url":"https://api.github.com/users/guwirth","html_url":"https://github.com/guwirth","followers_url":"https://api.github.com/users/guwirth/followers","following_url":"https://api.github.com/users/guwirth/following{/other_user}","gists_url":"https://api.github.com/users/guwirth/gists{/gist_id}","starred_url":"https://api.github.com/users/guwirth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guwirth/subscriptions","organizations_url":"https://api.github.com/users/guwirth/orgs","repos_url":"https://api.github.com/users/guwirth/repos","events_url":"https://api.github.com/users/guwirth/events{/privacy}","received_events_url":"https://api.github.com/users/guwirth/received_events","type":"User","site_admin":false},"created_at":"2015-02-14T07:11:43Z","updated_at":"2015-02-14T07:11:43Z","body":"Maybe wiki helps https://github.com/wenns/sonar-cxx/wiki/Path-and-path-separator-issues"}}