Skip to content

Commit

Permalink
defer timer stop
Browse files Browse the repository at this point in the history
  • Loading branch information
owenrumney-f3 committed Feb 9, 2021
1 parent f149a3b commit 13b9812
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/app/squealer/scan/git_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (s *gitScanner) Scan() error {
}

s.metrics.StartTimer()
defer s.metrics.StopTimer()
commit, err := commits.Next()
for err == nil && commit != nil {
func(c *object.Commit) {
Expand All @@ -83,7 +84,6 @@ func (s *gitScanner) Scan() error {
}
commit, err = commits.Next()
}
s.metrics.StopTimer()

if err != nil && err != io.EOF {
fmt.Printf("error is not null %s\n", err.Error())
Expand Down Expand Up @@ -158,15 +158,14 @@ func (s *gitScanner) processCommit(commit *object.Commit) error {
file, err = files.Next()
}

s.metrics.IncrementCommitsProcessed()
close(ch)
wg.Wait()

s.metrics.IncrementCommitsProcessed()
return nil
}

func (s *gitScanner) processFile(file *object.File) error {
s.metrics.IncrementFilesProcessed()

if isBin, err := file.IsBinary(); err != nil || isBin {
return nil
}
Expand All @@ -177,7 +176,10 @@ func (s *gitScanner) processFile(file *object.File) error {
if err != nil {
return err
}
return s.mc.Evaluate(file.Name, content)

err = s.mc.Evaluate(file.Name, content)
s.metrics.IncrementFilesProcessed()
return err
}

func (s *gitScanner) GetMetrics() *mertics.Metrics {
Expand Down

0 comments on commit 13b9812

Please sign in to comment.