Skip to content

Commit

Permalink
refactor: enable perfsprint to ensure performant string printing (#273
Browse files Browse the repository at this point in the history
)
  • Loading branch information
G-Rath authored Oct 28, 2024
1 parent 4ec0a91 commit aff459a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ linters:
- wsl # disagree with, for now
- ireturn # disagree with, sort of
- nonamedreturns # they have their uses
- perfsprint # enable in dedicated PR
presets:
- bugs
- comment
Expand Down
3 changes: 2 additions & 1 deletion internal/reporter/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package reporter_test
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"strings"
"testing"
Expand All @@ -11,7 +12,7 @@ import (
"github.com/g-rath/osv-detector/pkg/database"
)

var errOhNoes = fmt.Errorf("oh noes")
var errOhNoes = errors.New("oh noes")

type TestResult struct {
Value string `json:"value"`
Expand Down
5 changes: 1 addition & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@ func uniqueDBConfigs(configs []*configer.Config) []database.Config {
func describeDB(db database.DB) string {
switch tt := db.(type) {
case *database.APIDB:
return fmt.Sprintf(
"using batches of %s",
color.YellowString("%d", tt.BatchSize),
)
return "using batches of " + color.YellowString("%d", tt.BatchSize)
case *database.ZipDB:
count := tt.VulnerabilitiesCount

Expand Down
4 changes: 2 additions & 2 deletions pkg/semantic/version-pypi.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func normalizePyPILegacyPart(part string) string {
return fmt.Sprintf("%08s", part)
}

return fmt.Sprintf("*%s", part)
return "*" + part
}

func parsePyPIVersionParts(str string) (parts []string) {
Expand Down Expand Up @@ -191,7 +191,7 @@ func (pv PyPIVersion) preIndex() int {
}
}

panic(fmt.Sprintf("unknown prefix %s", pv.pre.letter))
panic("unknown prefix " + pv.pre.letter)
}

// Checks if this PyPIVersion should apply a sort trick when comparing pre,
Expand Down

0 comments on commit aff459a

Please sign in to comment.