@@ -17,7 +17,7 @@ object GoParser extends CoverageParser {
17
17
18
18
final val MODE = """ mode: ([set|count|atomic]*)""" .r
19
19
20
- // filename.go:lineFrom.column,lineTo.column numberOfStatements countOfStatements
20
+ // filename.go:lineFrom.column,lineTo.column numberOfStatements countOfStatements
21
21
final val regexpString = """ ([a-zA-Z\/\._\-\d]*):(\d+).*?,(\d+).* (\d+) (\d+)""" .r
22
22
23
23
override def parse (rootProject : File , reportFile : File ): Either [String , CoverageReport ] = {
@@ -40,24 +40,29 @@ object GoParser extends CoverageParser {
40
40
coverageInfoGroupedByFilename.foldLeft[Seq [CoverageFileReport ]](Seq .empty[CoverageFileReport ])((accum, next) => {
41
41
next match {
42
42
case (filename, coverageInfosForFile) =>
43
- // calculate hits for a file for given statement reports
43
+ // Only for Github - Process filename to remove "github.com/orgname/repositoryname/"
44
+ val processedFilename = if (filename.startsWith(" github.com/" )) {
45
+ filename.split(" /" , 4 ).lastOption.getOrElse(filename) // Get everything after repository name
46
+ } else {
47
+ filename
48
+ }
49
+
50
+ // Calculate hits for a file for given statement reports
44
51
val coverage = coverageInfosForFile.foldLeft(Map [Int , Int ]()) {
45
52
case (hitMapAcc, coverageInfo) =>
46
- // calculate the range of lines the statement has
53
+ // Calculate the range of lines the statement has
47
54
val lines = Range .inclusive(coverageInfo.lineFrom, coverageInfo.lineTo)
48
55
49
- // for each line add the number of hits
56
+ // For each line, add the number of hits
50
57
hitMapAcc ++ lines.foldLeft(Map [Int , Int ]()) {
51
58
case (statementHitMapAcc, line) =>
52
59
statementHitMapAcc ++
53
- // if the line is already present on the hit map, don't replace the value
60
+ // If the line is already present on the hit map, don't replace the value
54
61
Map (line -> (hitMapAcc.getOrElse(line, 0 ) + coverageInfo.countOfStatements))
55
-
56
62
}
57
63
}
58
64
59
- accum :+ CoverageFileReport (filename, coverage)
60
-
65
+ accum :+ CoverageFileReport (processedFilename, coverage)
61
66
}
62
67
})
63
68
@@ -70,5 +75,4 @@ object GoParser extends CoverageParser {
70
75
GoCoverageInfo (filename, lineFrom.toInt, lineTo.toInt, numberOfStatements.toInt, countOfStatements.toInt)
71
76
}
72
77
}
73
-
74
78
}
0 commit comments