Skip to content

Commit 817b3f7

Browse files
authored
Merge pull request #4 from bmwalters/sonarqube-relative
Update SonarqubeXmlConverter to produce relative paths
2 parents d7f876f + 3c478d9 commit 817b3f7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Sources/Core/Converters/SonarqubeXmlConverter.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ public extension Xccov.Converters {
1313

1414
public extension Xccov.Converters.SonarqubeXml {
1515
static func convert(coverageReport: CoverageReport) -> Result<String, Xccov.Error> {
16+
Self.convert(coverageReport: coverageReport,
17+
currentDirectoryPath: FileManager.default.currentDirectoryPath)
18+
}
19+
20+
static func convert(coverageReport: CoverageReport,
21+
currentDirectoryPath: String = FileManager.default.currentDirectoryPath) -> Result<String, Xccov.Error> {
1622
let rootElement = XMLElement(name: "coverage")
1723
rootElement.addAttribute(XMLNode.nodeAttribute(withName: "version", stringValue: "1"))
1824

@@ -23,7 +29,8 @@ public extension Xccov.Converters.SonarqubeXml {
2329

2430

2531
allFiles.forEach { fileCoverageReport in
26-
let filePath = fileCoverageReport.path
32+
// Define file path relative to source
33+
let filePath = fileCoverageReport.path.replacingOccurrences(of: currentDirectoryPath + "/", with: "")
2734

2835
let fileElement = XMLElement(name: "file")
2936
fileElement.addAttribute(XMLNode.nodeAttribute(withName: "path", stringValue: filePath))

0 commit comments

Comments
 (0)