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

Co-authored-by: Fernandez Ludovic <ldez@users.noreply.github.com>
This commit is contained in:
dependabot[bot] 2023-11-13 16:05:13 +01:00 committed by GitHub
parent b3146552ac
commit be5c2e930d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 36 additions and 14 deletions

View File

@ -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.

2
go.mod
View File

@ -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

4
go.sum generated
View File

@ -102,8 +102,8 @@ github.com/butuzov/ireturn v0.2.2 h1:jWI36dxXwVrI+RnXDwux2IZOewpmfv930OuIRfaBUJ0
github.com/butuzov/ireturn v0.2.2/go.mod h1:RfGHUvvAuFFxoHKf4Z8Yxuh6OjlCw1KvR2zM1NFHeBk=
github.com/butuzov/mirror v1.1.0 h1:ZqX54gBVMXu78QLoiqdwpl2mgmoOJTk7s4p4o+0avZI=
github.com/butuzov/mirror v1.1.0/go.mod h1:8Q0BdQU6rC6WILDiBM60DBfvV78OLJmMmixe7GF45AE=
github.com/catenacyber/perfsprint v0.3.0 h1:xMciPd+OYZd2oWJhoqBlnu4Vfe284ktxDZHQkmdjNrU=
github.com/catenacyber/perfsprint v0.3.0/go.mod h1:/wclWYompEyjUD2FuIIDVKNkqz7IgBIWXIH3V0Zol50=
github.com/catenacyber/perfsprint v0.3.1 h1:KGTSplWrKftfyqUrXAlk28z7HyoJjZWgvbjwv05fSIw=
github.com/catenacyber/perfsprint v0.3.1/go.mod h1:/wclWYompEyjUD2FuIIDVKNkqz7IgBIWXIH3V0Zol50=
github.com/ccojocar/zxcvbn-go v1.0.1 h1:+sxrANSCj6CdadkcMnvde/GWU1vZiiXRbqYSCalV4/4=
github.com/ccojocar/zxcvbn-go v1.0.1/go.mod h1:g1qkXtUSvHP8lhHp5GrSmTz6uWALGRMQdw6Qnz/hi60=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=

View File

@ -106,6 +106,9 @@ var defaultLintersSettings = LintersSettings{
},
PerfSprint: PerfSprintSettings{
IntConversion: true,
ErrError: false,
ErrorF: true,
SprintF1: true,
},
Prealloc: PreallocSettings{
Simple: true,
@ -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 {

View File

@ -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,
},
}
}

View File

@ -0,0 +1,7 @@
linters-settings:
perfsprint:
int-conversion: false
err-error: true
errorf: false
sprintf1: false

View File

@ -1,3 +0,0 @@
linters-settings:
perfsprint:
int-conversion: false

View File

@ -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"
@ -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)

View File

@ -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 (