Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance tweaks #285

Merged
merged 2 commits into from Jan 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion formatters/cobertura/cobertura.go
Expand Up @@ -87,7 +87,6 @@ func (r Formatter) Format() (formatters.Report, error) {
num++
}
}
sf.CalcLineCounts()
err = rep.AddSourceFile(sf)
if err != nil {
return rep, errors.WithStack(err)
Expand Down
7 changes: 4 additions & 3 deletions formatters/gcov/gcov.go
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/codeclimate/test-reporter/env"
"github.com/codeclimate/test-reporter/formatters"
"github.com/pkg/errors"
"gopkg.in/src-d/go-git.v4/plumbing/object"
)

// Formatter collects GCov files, parses them, then formats them into a single report.
Expand Down Expand Up @@ -55,8 +56,9 @@ func (f *Formatter) Format() (formatters.Report, error) {
return rep, err
}

gitHead, _ := env.GetHead()
for _, file := range f.FileNames {
sf, err := parseSourceFile(file)
sf, err := parseSourceFile(file, gitHead)
if err != nil {
return rep, errors.WithStack(err)
}
Expand All @@ -70,8 +72,7 @@ func (f *Formatter) Format() (formatters.Report, error) {
}

// Parse a single GCov source file.
func parseSourceFile(fileName string) (formatters.SourceFile, error) {
gitHead, _ := env.GetHead()
func parseSourceFile(fileName string, gitHead *object.Commit) (formatters.SourceFile, error) {
sf, err := formatters.NewSourceFile(fileName, gitHead)
if err != nil {
return sf, errors.WithStack(err)
Expand Down
1 change: 0 additions & 1 deletion formatters/jacoco/jacoco.go
Expand Up @@ -66,7 +66,6 @@ func (r Formatter) Format() (formatters.Report, error) {
sf.Coverage = append(sf.Coverage, ni)
num++
}
sf.CalcLineCounts()
err = rep.AddSourceFile(sf)
if err != nil {
return rep, errors.WithStack(err)
Expand Down