From cc4b7153ef7398726a1b50aaf4f30b8b2426f06f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 8 Feb 2025 17:08:55 +0000 Subject: [PATCH 1/3] build(deps): bump github.com/catenacyber/perfsprint from 0.7.1 to 0.8.0 Bumps [github.com/catenacyber/perfsprint](https://github.com/catenacyber/perfsprint) from 0.7.1 to 0.8.0. - [Commits](https://github.com/catenacyber/perfsprint/compare/v0.7.1...v0.8.0) --- updated-dependencies: - dependency-name: github.com/catenacyber/perfsprint dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index ea75ad10819e..197ee7484f10 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/breml/errchkjson v0.4.0 github.com/butuzov/ireturn v0.3.1 github.com/butuzov/mirror v1.3.0 - github.com/catenacyber/perfsprint v0.7.1 + github.com/catenacyber/perfsprint v0.8.0 github.com/charithe/durationcheck v0.0.10 github.com/ckaznocha/intrange v0.3.0 github.com/curioswitch/go-reassign v0.3.0 diff --git a/go.sum b/go.sum index f6cf53b23a8e..eb446d788279 100644 --- a/go.sum +++ b/go.sum @@ -102,8 +102,8 @@ github.com/butuzov/ireturn v0.3.1 h1:mFgbEI6m+9W8oP/oDdfA34dLisRFCj2G6o/yiI1yZrY github.com/butuzov/ireturn v0.3.1/go.mod h1:ZfRp+E7eJLC0NQmk1Nrm1LOrn/gQlOykv+cVPdiXH5M= github.com/butuzov/mirror v1.3.0 h1:HdWCXzmwlQHdVhwvsfBb2Au0r3HyINry3bDWLYXiKoc= github.com/butuzov/mirror v1.3.0/go.mod h1:AEij0Z8YMALaq4yQj9CPPVYOyJQyiexpQEQgihajRfI= -github.com/catenacyber/perfsprint v0.7.1 h1:PGW5G/Kxn+YrN04cRAZKC+ZuvlVwolYMrIyyTJ/rMmc= -github.com/catenacyber/perfsprint v0.7.1/go.mod h1:/wclWYompEyjUD2FuIIDVKNkqz7IgBIWXIH3V0Zol50= +github.com/catenacyber/perfsprint v0.8.0 h1:ut8XT1nZYfq/9iDc2T2KVwPfK0r0dpBBpk6gl4LiBsM= +github.com/catenacyber/perfsprint v0.8.0/go.mod h1:/wclWYompEyjUD2FuIIDVKNkqz7IgBIWXIH3V0Zol50= github.com/ccojocar/zxcvbn-go v1.0.2 h1:na/czXU8RrhXO4EZme6eQJLR4PzcGsahsBOAwU6I3Vg= github.com/ccojocar/zxcvbn-go v1.0.2/go.mod h1:g1qkXtUSvHP8lhHp5GrSmTz6uWALGRMQdw6Qnz/hi60= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -291,7 +291,6 @@ github.com/gostaticanalysis/nilerr v0.1.1 h1:ThE+hJP0fEp4zWLkWHWcRyI2Od0p7DlgYG3 github.com/gostaticanalysis/nilerr v0.1.1/go.mod h1:wZYb6YI5YAxxq0i1+VJbY0s2YONW0HU0GPE3+5PWN4A= github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod h1:D+FIZ+7OahH3ePw/izIEeH5I06eKs1IKI4Xr64/Am3M= github.com/gostaticanalysis/testutil v0.5.0 h1:Dq4wT1DdTwTGCQQv3rl3IvD5Ld0E6HiY+3Zh0sUGqw8= -github.com/gostaticanalysis/testutil v0.5.0/go.mod h1:OLQSbuM6zw2EvCcXTz1lVq5unyoNft372msDY0nY5Hs= github.com/hashicorp/go-immutable-radix/v2 v2.1.0 h1:CUW5RYIcysz+D3B+l1mDeXrQ7fUvGGCwJfdASSzbrfo= github.com/hashicorp/go-immutable-radix/v2 v2.1.0/go.mod h1:hgdqLXA4f6NIjRVisM1TJ9aOJVNRqKZj+xDGF6m7PBw= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= @@ -417,8 +416,6 @@ github.com/onsi/ginkgo/v2 v2.22.2/go.mod h1:oeMosUL+8LtarXBHu/c0bx2D/K9zyQ6uX3cT github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8= github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= -github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= -github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= @@ -548,9 +545,7 @@ github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/tdakkota/asciicheck v0.3.0 h1:LqDGgZdholxZMaJgpM6b0U9CFIjDCbFdUF00bDnBKOQ= github.com/tdakkota/asciicheck v0.3.0/go.mod h1:KoJKXuX/Z/lt6XzLo8WMBfQGzak0SrAKZlvRr4tg8Ac= -github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA= github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= -github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= github.com/tetafro/godot v1.4.20 h1:z/p8Ek55UdNvzt4TFn2zx2KscpW4rWqcnUrdmvWJj7E= github.com/tetafro/godot v1.4.20/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= From 2f47a737683b463a6cc535d6ae70c5829db71bf4 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 8 Feb 2025 18:09:26 +0100 Subject: [PATCH 2/3] chore: fix go.sum --- go.sum | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/go.sum b/go.sum index eb446d788279..fb7d758795d5 100644 --- a/go.sum +++ b/go.sum @@ -291,6 +291,7 @@ github.com/gostaticanalysis/nilerr v0.1.1 h1:ThE+hJP0fEp4zWLkWHWcRyI2Od0p7DlgYG3 github.com/gostaticanalysis/nilerr v0.1.1/go.mod h1:wZYb6YI5YAxxq0i1+VJbY0s2YONW0HU0GPE3+5PWN4A= github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod h1:D+FIZ+7OahH3ePw/izIEeH5I06eKs1IKI4Xr64/Am3M= github.com/gostaticanalysis/testutil v0.5.0 h1:Dq4wT1DdTwTGCQQv3rl3IvD5Ld0E6HiY+3Zh0sUGqw8= +github.com/gostaticanalysis/testutil v0.5.0/go.mod h1:OLQSbuM6zw2EvCcXTz1lVq5unyoNft372msDY0nY5Hs= github.com/hashicorp/go-immutable-radix/v2 v2.1.0 h1:CUW5RYIcysz+D3B+l1mDeXrQ7fUvGGCwJfdASSzbrfo= github.com/hashicorp/go-immutable-radix/v2 v2.1.0/go.mod h1:hgdqLXA4f6NIjRVisM1TJ9aOJVNRqKZj+xDGF6m7PBw= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= @@ -416,6 +417,8 @@ github.com/onsi/ginkgo/v2 v2.22.2/go.mod h1:oeMosUL+8LtarXBHu/c0bx2D/K9zyQ6uX3cT github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8= github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= +github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= +github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= @@ -545,7 +548,9 @@ github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/tdakkota/asciicheck v0.3.0 h1:LqDGgZdholxZMaJgpM6b0U9CFIjDCbFdUF00bDnBKOQ= github.com/tdakkota/asciicheck v0.3.0/go.mod h1:KoJKXuX/Z/lt6XzLo8WMBfQGzak0SrAKZlvRr4tg8Ac= +github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA= github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= +github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= github.com/tetafro/godot v1.4.20 h1:z/p8Ek55UdNvzt4TFn2zx2KscpW4rWqcnUrdmvWJj7E= github.com/tetafro/godot v1.4.20/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= From 9948d95d4a6064e660323729dface9a1d407ef8c Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sat, 8 Feb 2025 18:09:42 +0100 Subject: [PATCH 3/3] chore: update implementation --- .golangci.next.reference.yml | 16 ++++++++++++++- jsonschema/golangci.next.jsonschema.json | 25 ++++++++++++++++++++++++ pkg/config/linters_settings.go | 21 ++++++++++++++++---- pkg/golinters/perfsprint/perfsprint.go | 8 ++++++++ 4 files changed, 65 insertions(+), 5 deletions(-) diff --git a/.golangci.next.reference.yml b/.golangci.next.reference.yml index 51cbdc384f0b..35548095a804 100644 --- a/.golangci.next.reference.yml +++ b/.golangci.next.reference.yml @@ -2243,23 +2243,37 @@ linters-settings: # still required to have `t.Parallel`, but subtests are allowed to skip it. # Default: false ignore-missing-subtests: true - perfsprint: + # Enable/disable optimization of integer formatting. + # Default: true + integer-format: false # Optimizes even if it requires an int or uint type cast. # Default: true int-conversion: false + # Enable/disable optimization of error formatting. + # Default: true + error-format: 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 + # Enable/disable optimization of string formatting. + # Default: true + string-format: false # Optimizes `fmt.Sprintf` with only one argument. # Default: true sprintf1: false # Optimizes into strings concatenation. # Default: true strconcat: false + # Enable/disable optimization of bool formatting. + # Default: true + bool-format: false + # Enable/disable optimization of hex formatting. + # Default: true + hex-format: false prealloc: # IMPORTANT: we don't recommend using this linter before doing performance profiling. diff --git a/jsonschema/golangci.next.jsonschema.json b/jsonschema/golangci.next.jsonschema.json index 64c2d3f51f2b..5249a96aa006 100644 --- a/jsonschema/golangci.next.jsonschema.json +++ b/jsonschema/golangci.next.jsonschema.json @@ -2472,11 +2472,21 @@ "type": "object", "additionalProperties": false, "properties": { + "integer-format": { + "description": "Enable/disable optimization of integer formatting.", + "type": "boolean", + "default": true + }, "int-conversion": { "description": "Optimizes even if it requires an int or uint type cast.", "type": "boolean", "default": true }, + "error-format": { + "description": "Enable/disable optimization of error formatting.", + "type": "boolean", + "default": true + }, "err-error": { "description": "Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.", "type": "boolean", @@ -2487,6 +2497,11 @@ "type": "boolean", "default": true }, + "string-format": { + "description": "Enable/disable optimization of string formatting.", + "type": "boolean", + "default": true + }, "sprintf1": { "description": "Optimizes `fmt.Sprintf` with only one argument.", "type": "boolean", @@ -2496,6 +2511,16 @@ "description": "Optimizes into strings concatenation.", "type": "boolean", "default": true + }, + "bool-format": { + "description": "Enable/disable optimization of bool formatting.", + "type": "boolean", + "default": true + }, + "hex-format": { + "description": "Enable/disable optimization of hex formatting.", + "type": "boolean", + "default": true } } }, diff --git a/pkg/config/linters_settings.go b/pkg/config/linters_settings.go index eb274ba774fc..94650a66de9b 100644 --- a/pkg/config/linters_settings.go +++ b/pkg/config/linters_settings.go @@ -126,11 +126,16 @@ var defaultLintersSettings = LintersSettings{ AllowUnused: false, }, PerfSprint: PerfSprintSettings{ + IntegerFormat: true, IntConversion: true, + ErrorFormat: true, ErrError: false, ErrorF: true, + StringFormat: true, SprintF1: true, StrConcat: true, + BoolFormat: true, + HexFormat: true, }, Prealloc: PreallocSettings{ Simple: true, @@ -791,11 +796,19 @@ type ParallelTestSettings struct { } type PerfSprintSettings struct { + IntegerFormat bool `mapstructure:"integer-format"` IntConversion bool `mapstructure:"int-conversion"` - ErrError bool `mapstructure:"err-error"` - ErrorF bool `mapstructure:"errorf"` - SprintF1 bool `mapstructure:"sprintf1"` - StrConcat bool `mapstructure:"strconcat"` + + ErrorFormat bool `mapstructure:"error-format"` + ErrError bool `mapstructure:"err-error"` + ErrorF bool `mapstructure:"errorf"` + + StringFormat bool `mapstructure:"string-format"` + SprintF1 bool `mapstructure:"sprintf1"` + StrConcat bool `mapstructure:"strconcat"` + + BoolFormat bool `mapstructure:"bool-format"` + HexFormat bool `mapstructure:"hex-format"` } type PreallocSettings struct { diff --git a/pkg/golinters/perfsprint/perfsprint.go b/pkg/golinters/perfsprint/perfsprint.go index a4ead1914d2c..c34f7e4c629a 100644 --- a/pkg/golinters/perfsprint/perfsprint.go +++ b/pkg/golinters/perfsprint/perfsprint.go @@ -16,11 +16,19 @@ func New(settings *config.PerfSprintSettings) *goanalysis.Linter { } if settings != nil { + cfg[a.Name]["integer-format"] = settings.IntegerFormat cfg[a.Name]["int-conversion"] = settings.IntConversion + + cfg[a.Name]["error-format"] = settings.ErrorFormat cfg[a.Name]["err-error"] = settings.ErrError cfg[a.Name]["errorf"] = settings.ErrorF + + cfg[a.Name]["string-format"] = settings.StringFormat cfg[a.Name]["sprintf1"] = settings.SprintF1 cfg[a.Name]["strconcat"] = settings.StrConcat + + cfg[a.Name]["bool-format"] = settings.BoolFormat + cfg[a.Name]["hex-format"] = settings.HexFormat } return goanalysis.NewLinter(