Skip to content

Commit d8da91a

Browse files
silverwindclaude
andauthored
Update golangci-lint to v2.11.4 (#37059)
Update golangci-lint from v2.11.2 to v2.11.4 and fix new `modernize` lint warnings: - Use `strings.Builder` instead of string concatenation in loop (`evaluator.go`) - Use `atomic.Int64` instead of `int64` with atomic free functions (`logchecker.go`, `timer_test.go`, `integration_test.go`) --- This PR was written with the help of Claude Opus 4.6 Co-authored-by: Claude (Opus 4.6) <noreply@anthropic.com>
1 parent b20b0ed commit d8da91a

5 files changed

Lines changed: 23 additions & 23 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ XGO_VERSION := go-1.25.x
1515
AIR_PACKAGE ?= github.com/air-verse/air@v1
1616
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3
1717
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.9.2
18-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.2
18+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.4
1919
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.15
2020
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.8.0
2121
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.33.1

modules/actions/jobparser/evaluator.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func rewriteSubExpression(in string, forceFormat bool) (string, error) {
135135
exprStart := -1
136136
strStart := -1
137137
var results []string
138-
formatOut := ""
138+
var formatOut strings.Builder
139139
for pos < len(in) {
140140
if strStart > -1 {
141141
matches := strPattern.FindStringIndex(in[pos:])
@@ -158,7 +158,7 @@ func rewriteSubExpression(in string, forceFormat bool) (string, error) {
158158
}
159159

160160
if exprEnd > -1 {
161-
formatOut += fmt.Sprintf("{%d}", len(results))
161+
fmt.Fprintf(&formatOut, "{%d}", len(results))
162162
results = append(results, strings.TrimSpace(in[exprStart:pos+exprEnd]))
163163
pos += exprEnd + 2
164164
exprStart = -1
@@ -170,20 +170,20 @@ func rewriteSubExpression(in string, forceFormat bool) (string, error) {
170170
} else {
171171
exprStart = strings.Index(in[pos:], "${{")
172172
if exprStart != -1 {
173-
formatOut += escapeFormatString(in[pos : pos+exprStart])
173+
formatOut.WriteString(escapeFormatString(in[pos : pos+exprStart]))
174174
exprStart = pos + exprStart + 3
175175
pos = exprStart
176176
} else {
177-
formatOut += escapeFormatString(in[pos:])
177+
formatOut.WriteString(escapeFormatString(in[pos:]))
178178
pos = len(in)
179179
}
180180
}
181181
}
182182

183-
if len(results) == 1 && formatOut == "{0}" && !forceFormat {
183+
if len(results) == 1 && formatOut.String() == "{0}" && !forceFormat {
184184
return in, nil
185185
}
186186

187-
out := fmt.Sprintf("format('%s', %s)", strings.ReplaceAll(formatOut, "'", "''"), strings.Join(results, ", "))
187+
out := fmt.Sprintf("format('%s', %s)", strings.ReplaceAll(formatOut.String(), "'", "''"), strings.Join(results, ", "))
188188
return out, nil
189189
}

modules/test/logchecker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ func (lc *LogChecker) checkLogEvent(event *log.EventFormatted) {
5353
}
5454
}
5555

56-
var checkerIndex int64
56+
var checkerIndex atomic.Int64
5757

5858
func NewLogChecker(namePrefix string) (logChecker *LogChecker, cancel func()) {
5959
logger := log.GetManager().GetLogger(namePrefix)
60-
newCheckerIndex := atomic.AddInt64(&checkerIndex, 1)
60+
newCheckerIndex := checkerIndex.Add(1)
6161
writerName := namePrefix + "-" + strconv.FormatInt(newCheckerIndex, 10)
6262

6363
lc := &LogChecker{}

modules/util/timer_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ import (
1212
)
1313

1414
func TestDebounce(t *testing.T) {
15-
var c int64
15+
var c atomic.Int64
1616
d := Debounce(50 * time.Millisecond)
17-
d(func() { atomic.AddInt64(&c, 1) })
18-
assert.EqualValues(t, 0, atomic.LoadInt64(&c))
19-
d(func() { atomic.AddInt64(&c, 1) })
20-
d(func() { atomic.AddInt64(&c, 1) })
17+
d(func() { c.Add(1) })
18+
assert.EqualValues(t, 0, c.Load())
19+
d(func() { c.Add(1) })
20+
d(func() { c.Add(1) })
2121
time.Sleep(100 * time.Millisecond)
22-
assert.EqualValues(t, 1, atomic.LoadInt64(&c))
23-
d(func() { atomic.AddInt64(&c, 1) })
24-
assert.EqualValues(t, 1, atomic.LoadInt64(&c))
25-
d(func() { atomic.AddInt64(&c, 1) })
26-
d(func() { atomic.AddInt64(&c, 1) })
27-
d(func() { atomic.AddInt64(&c, 1) })
22+
assert.EqualValues(t, 1, c.Load())
23+
d(func() { c.Add(1) })
24+
assert.EqualValues(t, 1, c.Load())
25+
d(func() { c.Add(1) })
26+
d(func() { c.Add(1) })
27+
d(func() { c.Add(1) })
2828
time.Sleep(100 * time.Millisecond)
29-
assert.EqualValues(t, 2, atomic.LoadInt64(&c))
29+
assert.EqualValues(t, 2, c.Load())
3030
}

tests/integration/integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,13 @@ func loginUserWithPassword(t testing.TB, userName, password string) *TestSession
246246
}
247247

248248
// token has to be unique this counter take care of
249-
var tokenCounter int64
249+
var tokenCounter atomic.Int64
250250

251251
// getTokenForLoggedInUser returns a token for a logged-in user.
252252
func getTokenForLoggedInUser(t testing.TB, session *TestSession, scopes ...auth.AccessTokenScope) string {
253253
t.Helper()
254254
urlValues := url.Values{}
255-
urlValues.Add("name", fmt.Sprintf("api-testing-token-%d", atomic.AddInt64(&tokenCounter, 1)))
255+
urlValues.Add("name", fmt.Sprintf("api-testing-token-%d", tokenCounter.Add(1)))
256256
for _, scope := range scopes {
257257
urlValues.Add("scope-dummy", string(scope)) // it only needs to start with "scope-" to be accepted
258258
}

0 commit comments

Comments
 (0)