From 1200be22ace3ba655d38eacccaf8e53cd336a20c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 8 Feb 2025 18:33:02 +0100 Subject: [PATCH] build(deps): bump github.com/catenacyber/perfsprint from 0.7.1 to 0.8.0 (#5382) Co-authored-by: Fernandez Ludovic --- .golangci.next.reference.yml | 16 ++++++++++++++- go.mod | 2 +- go.sum | 4 ++-- jsonschema/golangci.next.jsonschema.json | 25 ++++++++++++++++++++++++ pkg/config/linters_settings.go | 21 ++++++++++++++++---- pkg/golinters/perfsprint/perfsprint.go | 8 ++++++++ 6 files changed, 68 insertions(+), 8 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/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..fb7d758795d5 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= 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(