Skip to content

Commit

Permalink
refactor(github): change scanErrs.String output
Browse files Browse the repository at this point in the history
  • Loading branch information
rgmz authored and Richard Gomez committed Feb 9, 2024
1 parent 4849e02 commit 135dc20
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions pkg/sources/errors.go
Expand Up @@ -2,7 +2,7 @@ package sources

import (
"errors"
"fmt"
"strings"
"sync"
)

Expand Down Expand Up @@ -35,7 +35,17 @@ func (s *ScanErrors) Count() uint64 {
func (s *ScanErrors) String() string {
s.mu.RLock()
defer s.mu.RUnlock()
return fmt.Sprintf("%v", s.errors)

var sb strings.Builder
sb.WriteString("[")
for i, err := range s.errors {
sb.WriteString(`"` + err.Error() + `"`)
if i < len(s.errors)-1 {
sb.WriteString(", ")
}
}
sb.WriteString("]")
return sb.String()
}

func (s *ScanErrors) Errors() error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sources/github/github.go
Expand Up @@ -748,7 +748,7 @@ func (s *Source) scan(ctx context.Context, installationClient *github.Client, ch

_ = s.jobPool.Wait()
if scanErrs.Count() > 0 {
s.log.V(0).Info("failed to scan some repositories", "error_count", scanErrs.Count(), "errors", scanErrs)
s.log.V(0).Info("failed to scan some repositories", "error_count", scanErrs.Count(), "errors", scanErrs.String())
}
s.SetProgressComplete(len(s.repos), len(s.repos), "Completed GitHub scan", "")

Expand Down

0 comments on commit 135dc20

Please sign in to comment.