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

build(deps): bump github.com/catenacyber/perfsprint from 0.3.0 to 0.3.1 #4199

Merged
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
9 changes: 9 additions & 0 deletions .golangci.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,15 @@ linters-settings:
# Optimizes even if it requires an int or uint type cast.
# Default: true
int-conversion: false
# Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.
# Default: false
err-error: true
# Optimizes `fmt.Errorf`.
# Default: true
errorf: false
# Optimizes `fmt.Sprintf` with only one argument
# Default: true
sprintf1: false

prealloc:
# IMPORTANT: we don't recommend using this linter before doing performance profiling.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ require (
github.com/breml/errchkjson v0.3.6
github.com/butuzov/ireturn v0.2.2
github.com/butuzov/mirror v1.1.0
github.com/catenacyber/perfsprint v0.3.0
github.com/catenacyber/perfsprint v0.3.1
github.com/charithe/durationcheck v0.0.10
github.com/curioswitch/go-reassign v0.2.0
github.com/daixiang0/gci v0.11.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/config/linters_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ var defaultLintersSettings = LintersSettings{
},
PerfSprint: PerfSprintSettings{
IntConversion: true,
ErrError: false,
ErrorF: true,
SprintF1: true,
},
Prealloc: PreallocSettings{
Simple: true,
Expand Down Expand Up @@ -691,6 +694,9 @@ type ParallelTestSettings struct {

type PerfSprintSettings struct {
IntConversion bool `mapstructure:"int-conversion"`
ErrError bool `mapstructure:"err-error"`
ErrorF bool `mapstructure:"errorf"`
SprintF1 bool `mapstructure:"sprintf1"`
}

type PreallocSettings struct {
Expand Down
3 changes: 3 additions & 0 deletions pkg/golinters/perfsprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func NewPerfSprint(settings *config.PerfSprintSettings) *goanalysis.Linter {
cfg = map[string]map[string]any{
a.Name: {
"int-conversion": settings.IntConversion,
"err-error": settings.ErrError,
"errorf": settings.ErrorF,
"sprintf1": settings.SprintF1,
},
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/testdata/configs/perfsprint_custom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
linters-settings:
perfsprint:
int-conversion: false
err-error: true
errorf: false
sprintf1: false

3 changes: 0 additions & 3 deletions test/testdata/configs/perfsprint_int_conversion.yml

This file was deleted.

14 changes: 7 additions & 7 deletions test/testdata/perfsprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ func TestPerfsprint() {
ui uint
)

fmt.Sprintf("%s", s) // want "fmt.Sprintf can be replaced with just using the string"
fmt.Sprint(s) // want "fmt.Sprint can be replaced with just using the string"
fmt.Sprintf("%s", err) // want "fmt.Sprintf can be replaced with err.Error()"
fmt.Sprint(err) // want "fmt.Sprint can be replaced with err.Error()"
fmt.Sprintf("%s", s) // want "fmt.Sprintf can be replaced with just using the string"
fmt.Sprint(s) // want "fmt.Sprint can be replaced with just using the string"
fmt.Sprintf("%s", err)
fmt.Sprint(err)
fmt.Sprintf("%t", b) // want "fmt.Sprintf can be replaced with faster strconv.FormatBool"
fmt.Sprint(b) // want "fmt.Sprint can be replaced with faster strconv.FormatBool"
fmt.Sprintf("%d", i) // want "fmt.Sprintf can be replaced with faster strconv.Itoa"
Expand All @@ -33,9 +33,9 @@ func TestPerfsprint() {

fmt.Sprint("test", 42)
fmt.Sprint(42, 42)
fmt.Sprintf("test")
fmt.Sprintf("%v")
fmt.Sprintf("%d")
fmt.Sprintf("test") // want "fmt.Sprintf can be replaced with just using the string"
fmt.Sprintf("%v") // want "fmt.Sprintf can be replaced with just using the string"
fmt.Sprintf("%d") // want "fmt.Sprintf can be replaced with just using the string"
fmt.Sprintf("%d", 42, 42)
fmt.Sprintf("%#d", 42)
fmt.Sprintf("value %d", 42)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//golangcitest:args -Eperfsprint
//golangcitest:config_path testdata/configs/perfsprint_int_conversion.yml
//golangcitest:config_path testdata/configs/perfsprint_custom.yml
package testdata

import (
Expand Down
Loading