From 74736d53a7a871f152f0699532f980aee71631d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Sat, 9 Mar 2024 12:44:14 +0200 Subject: [PATCH] perf: address perfsprint linter findings Enable the linter, but exclude fmt.Sprintf -> concatenation, as the former is arguably often more readable. --- .golangci.yml | 7 +++++++ internal/lefthook/install.go | 4 ++-- internal/log/skip_settings_test.go | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 3a328480..649387c3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,6 +15,12 @@ linters-settings: - name: unused-parameter disabled: true +issues: + exclude: + # https://github.com/catenacyber/perfsprint/issues/21 + # https://github.com/catenacyber/perfsprint/issues/23 + - "^fmt\\.Sprintf can be replaced with string (addi|concatena)tion$" + linters: disable-all: true enable: @@ -57,6 +63,7 @@ linters: - nestif - noctx - nolintlint + - perfsprint - predeclared - reassign - revive diff --git a/internal/lefthook/install.go b/internal/lefthook/install.go index 549f207d..a90b552b 100644 --- a/internal/lefthook/install.go +++ b/internal/lefthook/install.go @@ -4,7 +4,7 @@ import ( "bufio" "crypto/md5" "encoding/hex" - "fmt" + "errors" "io" "os" "path/filepath" @@ -31,7 +31,7 @@ const ( var ( lefthookChecksumRegexp = regexp.MustCompile(`(\w+)\s+(\d+)`) configGlob = glob.MustCompile("{.,}lefthook.{yml,yaml,json,toml}") - errNoConfig = fmt.Errorf("no lefthook config found") + errNoConfig = errors.New("no lefthook config found") ) // Install installs the hooks from config file to the .git/hooks. diff --git a/internal/log/skip_settings_test.go b/internal/log/skip_settings_test.go index f2f85e9f..88aa9404 100644 --- a/internal/log/skip_settings_test.go +++ b/internal/log/skip_settings_test.go @@ -1,7 +1,7 @@ package log import ( - "fmt" + "strconv" "testing" ) @@ -85,7 +85,7 @@ func TestSkipSetting(t *testing.T) { }, }, } { - t.Run(fmt.Sprintf("%d", i), func(t *testing.T) { + t.Run(strconv.Itoa(i), func(t *testing.T) { var settings SkipSettings (&settings).ApplySettings(tt.tags, tt.settings)