Skip to content

Commit be5c2e9

Browse files
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>
1 parent b314655 commit be5c2e9

File tree

9 files changed

+36
-14
lines changed

9 files changed

+36
-14
lines changed

.golangci.reference.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,6 +1387,15 @@ linters-settings:
13871387
# Optimizes even if it requires an int or uint type cast.
13881388
# Default: true
13891389
int-conversion: false
1390+
# Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.
1391+
# Default: false
1392+
err-error: true
1393+
# Optimizes `fmt.Errorf`.
1394+
# Default: true
1395+
errorf: false
1396+
# Optimizes `fmt.Sprintf` with only one argument
1397+
# Default: true
1398+
sprintf1: false
13901399

13911400
prealloc:
13921401
# IMPORTANT: we don't recommend using this linter before doing performance profiling.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ require (
2727
github.com/breml/errchkjson v0.3.6
2828
github.com/butuzov/ireturn v0.2.2
2929
github.com/butuzov/mirror v1.1.0
30-
github.com/catenacyber/perfsprint v0.3.0
30+
github.com/catenacyber/perfsprint v0.3.1
3131
github.com/charithe/durationcheck v0.0.10
3232
github.com/curioswitch/go-reassign v0.2.0
3333
github.com/daixiang0/gci v0.11.2

go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/linters_settings.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ var defaultLintersSettings = LintersSettings{
106106
},
107107
PerfSprint: PerfSprintSettings{
108108
IntConversion: true,
109+
ErrError: false,
110+
ErrorF: true,
111+
SprintF1: true,
109112
},
110113
Prealloc: PreallocSettings{
111114
Simple: true,
@@ -691,6 +694,9 @@ type ParallelTestSettings struct {
691694

692695
type PerfSprintSettings struct {
693696
IntConversion bool `mapstructure:"int-conversion"`
697+
ErrError bool `mapstructure:"err-error"`
698+
ErrorF bool `mapstructure:"errorf"`
699+
SprintF1 bool `mapstructure:"sprintf1"`
694700
}
695701

696702
type PreallocSettings struct {

pkg/golinters/perfsprint.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ func NewPerfSprint(settings *config.PerfSprintSettings) *goanalysis.Linter {
1616
cfg = map[string]map[string]any{
1717
a.Name: {
1818
"int-conversion": settings.IntConversion,
19+
"err-error": settings.ErrError,
20+
"errorf": settings.ErrorF,
21+
"sprintf1": settings.SprintF1,
1922
},
2023
}
2124
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
linters-settings:
2+
perfsprint:
3+
int-conversion: false
4+
err-error: true
5+
errorf: false
6+
sprintf1: false
7+

test/testdata/configs/perfsprint_int_conversion.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/testdata/perfsprint.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ func TestPerfsprint() {
1515
ui uint
1616
)
1717

18-
fmt.Sprintf("%s", s) // want "fmt.Sprintf can be replaced with just using the string"
19-
fmt.Sprint(s) // want "fmt.Sprint can be replaced with just using the string"
20-
fmt.Sprintf("%s", err) // want "fmt.Sprintf can be replaced with err.Error()"
21-
fmt.Sprint(err) // want "fmt.Sprint can be replaced with err.Error()"
18+
fmt.Sprintf("%s", s) // want "fmt.Sprintf can be replaced with just using the string"
19+
fmt.Sprint(s) // want "fmt.Sprint can be replaced with just using the string"
20+
fmt.Sprintf("%s", err)
21+
fmt.Sprint(err)
2222
fmt.Sprintf("%t", b) // want "fmt.Sprintf can be replaced with faster strconv.FormatBool"
2323
fmt.Sprint(b) // want "fmt.Sprint can be replaced with faster strconv.FormatBool"
2424
fmt.Sprintf("%d", i) // want "fmt.Sprintf can be replaced with faster strconv.Itoa"
@@ -33,9 +33,9 @@ func TestPerfsprint() {
3333

3434
fmt.Sprint("test", 42)
3535
fmt.Sprint(42, 42)
36-
fmt.Sprintf("test")
37-
fmt.Sprintf("%v")
38-
fmt.Sprintf("%d")
36+
fmt.Sprintf("test") // want "fmt.Sprintf can be replaced with just using the string"
37+
fmt.Sprintf("%v") // want "fmt.Sprintf can be replaced with just using the string"
38+
fmt.Sprintf("%d") // want "fmt.Sprintf can be replaced with just using the string"
3939
fmt.Sprintf("%d", 42, 42)
4040
fmt.Sprintf("%#d", 42)
4141
fmt.Sprintf("value %d", 42)

test/testdata/perfsprint_int_conversion.go renamed to test/testdata/perfsprint_custom.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//golangcitest:args -Eperfsprint
2-
//golangcitest:config_path testdata/configs/perfsprint_int_conversion.yml
2+
//golangcitest:config_path testdata/configs/perfsprint_custom.yml
33
package testdata
44

55
import (

0 commit comments

Comments
 (0)