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

refactor: enable perfsprint to ensure performant string printing #273

Merged
merged 1 commit into from
Oct 28, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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