Skip to content

Commit

Permalink
fix coverage being under-reported due to over-counting of files
Browse files Browse the repository at this point in the history
  • Loading branch information
imsky committed Jun 12, 2018
1 parent 6953aaf commit 46c3ee1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func GetLines() []Line {

func ComputeTotalCoverage(sourceFiles map[string][]SourceFile) float64 {
var totalCoverage float64
totalFiles := 0

//todo: validate that each source file list of lines is same length
for _, fileSets := range sourceFiles {
Expand All @@ -49,11 +50,12 @@ func ComputeTotalCoverage(sourceFiles map[string][]SourceFile) float64 {
}

if totalLines > 0 {
totalFiles++
totalCoverage += float64(hitLines) / float64(totalLines)
}
}

return (totalCoverage / float64(len(sourceFiles))) * 100
return (totalCoverage / float64(totalFiles)) * 100
}

func Run(reports []string) {
Expand Down

0 comments on commit 46c3ee1

Please sign in to comment.