Skip to content

Commit 0e7dc9e

Browse files
committed
Update golangci-lint to v2.6.0
1 parent ef90bef commit 0e7dc9e

File tree

25 files changed

+100
-48
lines changed

25 files changed

+100
-48
lines changed

.golangci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ linters:
1414
- govet
1515
- ineffassign
1616
- mirror
17+
- modernize
1718
- nakedret
1819
- nolintlint
19-
- perfsprint
2020
- revive
2121
- staticcheck
2222
- testifylint
@@ -55,6 +55,7 @@ linters:
5555
disabled-checks:
5656
- ifElseChain
5757
- singleCaseSwitch # Every time this occurred in the code, there was no other way.
58+
- deprecatedComment # conflicts with go-swagger comments
5859
revive:
5960
severity: error
6061
rules:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ XGO_VERSION := go-1.25.x
3232
AIR_PACKAGE ?= github.com/air-verse/air@v1
3333
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3
3434
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
35-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.5.0
35+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0
3636
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3737
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
3838
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]

models/asymkey/ssh_key_parse.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func parseKeyString(content string) (string, error) {
6666
lines := strings.Split(content, "\n")
6767
continuationLine := false
6868

69+
var keyContentSb69 strings.Builder
6970
for _, line := range lines {
7071
// Skip lines that:
7172
// 1) are a continuation of the previous line,
@@ -74,9 +75,10 @@ func parseKeyString(content string) (string, error) {
7475
if continuationLine || strings.ContainsAny(line, ":-") {
7576
continuationLine = strings.HasSuffix(line, "\\")
7677
} else {
77-
keyContent += line
78+
keyContentSb69.WriteString(line)
7879
}
7980
}
81+
keyContent += keyContentSb69.String()
8082

8183
t, err := extractTypeFromBase64Key(keyContent)
8284
if err != nil {

models/perm/access/repo_permission.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"errors"
99
"fmt"
1010
"slices"
11+
"strings"
1112

1213
actions_model "code.gitea.io/gitea/models/actions"
1314
"code.gitea.io/gitea/models/db"
@@ -171,6 +172,7 @@ func (p *Permission) LogString() string {
171172
format := "<Permission AccessMode=%s, %d Units, %d UnitsMode(s): ["
172173
args := []any{p.AccessMode.ToString(), len(p.units), len(p.unitsMode)}
173174

175+
var formatSb174 strings.Builder
174176
for i, u := range p.units {
175177
config := ""
176178
if u.Config != nil {
@@ -180,13 +182,16 @@ func (p *Permission) LogString() string {
180182
config = err.Error()
181183
}
182184
}
183-
format += "\n\tunits[%d]: ID=%d RepoID=%d Type=%s Config=%s"
185+
formatSb174.WriteString("\n\tunits[%d]: ID=%d RepoID=%d Type=%s Config=%s")
184186
args = append(args, i, u.ID, u.RepoID, u.Type.LogString(), config)
185187
}
188+
format += formatSb174.String()
189+
var formatSb186 strings.Builder
186190
for key, value := range p.unitsMode {
187-
format += "\n\tunitsMode[%-v]: %-v"
191+
formatSb186.WriteString("\n\tunitsMode[%-v]: %-v")
188192
args = append(args, key.LogString(), value.LogString())
189193
}
194+
format += formatSb186.String()
190195
format += "\n\tanonymousAccessMode: %-v"
191196
args = append(args, p.anonymousAccessMode)
192197
format += "\n\teveryoneAccessMode: %-v"

models/user/user.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,8 +1262,8 @@ func GetUserByEmail(ctx context.Context, email string) (*User, error) {
12621262
}
12631263

12641264
// Finally, if email address is the protected email address:
1265-
if strings.HasSuffix(email, "@"+setting.Service.NoReplyAddress) {
1266-
username := strings.TrimSuffix(email, "@"+setting.Service.NoReplyAddress)
1265+
if before, ok := strings.CutSuffix(email, "@"+setting.Service.NoReplyAddress); ok {
1266+
username := before
12671267
user := &User{}
12681268
has, err := db.GetEngine(ctx).Where("lower_name=?", username).Get(user)
12691269
if err != nil {

modules/auth/password/password.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,22 @@ func NewComplexity() {
6262

6363
func setupComplexity(values []string) {
6464
if len(values) != 1 || values[0] != "off" {
65+
var validCharsSb65 strings.Builder
6566
for _, val := range values {
6667
if complexity, ok := charComplexities[val]; ok {
67-
validChars += complexity.ValidChars
68+
validCharsSb65.WriteString(complexity.ValidChars)
6869
requiredList = append(requiredList, complexity)
6970
}
7071
}
72+
validChars += validCharsSb65.String()
7173
if len(requiredList) == 0 {
7274
// No valid character classes found; use all classes as default
75+
var validCharsSb73 strings.Builder
7376
for _, complexity := range charComplexities {
74-
validChars += complexity.ValidChars
77+
validCharsSb73.WriteString(complexity.ValidChars)
7578
requiredList = append(requiredList, complexity)
7679
}
80+
validChars += validCharsSb73.String()
7781
}
7882
}
7983
if validChars == "" {

modules/git/foreachref/format.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ func (f Format) Parser(r io.Reader) *Parser {
7676
// would turn into "%0a%00".
7777
func (f Format) hexEscaped(delim []byte) string {
7878
escaped := ""
79+
var escapedSb79 strings.Builder
7980
for i := range delim {
80-
escaped += "%" + hex.EncodeToString([]byte{delim[i]})
81+
escapedSb79.WriteString("%" + hex.EncodeToString([]byte{delim[i]}))
8182
}
83+
escaped += escapedSb79.String()
8284
return escaped
8385
}

modules/git/notes_nogogit.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,16 @@ func GetNote(ctx context.Context, repo *Repository, commitID string, note *Note)
3333

3434
var entry *TreeEntry
3535
originalCommitID := commitID
36+
var pathSb36 strings.Builder
3637
for len(commitID) > 2 {
3738
entry, err = tree.GetTreeEntryByPath(commitID)
3839
if err == nil {
39-
path += commitID
40+
pathSb36.WriteString(commitID)
4041
break
4142
}
4243
if IsErrNotExist(err) {
4344
tree, err = tree.SubTree(commitID[0:2])
44-
path += commitID[0:2] + "/"
45+
pathSb36.WriteString(commitID[0:2] + "/")
4546
commitID = commitID[2:]
4647
}
4748
if err != nil {
@@ -52,6 +53,7 @@ func GetNote(ctx context.Context, repo *Repository, commitID string, note *Note)
5253
return err
5354
}
5455
}
56+
path += pathSb36.String()
5557

5658
blob := entry.Blob()
5759
dataRc, err := blob.DataAsync()

modules/setting/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package setting
55

66
import (
7+
"strings"
78
"sync"
89

910
"code.gitea.io/gitea/modules/log"
@@ -24,9 +25,11 @@ type OpenWithEditorAppsType []OpenWithEditorApp
2425

2526
func (t OpenWithEditorAppsType) ToTextareaString() string {
2627
ret := ""
28+
var retSb27 strings.Builder
2729
for _, app := range t {
28-
ret += app.DisplayName + " = " + app.OpenURL + "\n"
30+
retSb27.WriteString(app.DisplayName + " = " + app.OpenURL + "\n")
2931
}
32+
ret += retSb27.String()
3033
return ret
3134
}
3235

modules/setting/config_env.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,20 @@ func decodeEnvSectionKey(encoded string) (ok bool, section, key string) {
4848
inKey := false
4949
last := 0
5050
escapeStringIndices := escapeRegex.FindAllStringIndex(encoded, -1)
51+
var keySb51 strings.Builder
52+
var sectionSb51 strings.Builder
5153
for _, unescapeIdx := range escapeStringIndices {
5254
preceding := encoded[last:unescapeIdx[0]]
5355
if !inKey {
5456
if splitter := strings.Index(preceding, "__"); splitter > -1 {
55-
section += preceding[:splitter]
57+
sectionSb51.WriteString(preceding[:splitter])
5658
inKey = true
57-
key += preceding[splitter+2:]
59+
keySb51.WriteString(preceding[splitter+2:])
5860
} else {
59-
section += preceding
61+
sectionSb51.WriteString(preceding)
6062
}
6163
} else {
62-
key += preceding
64+
keySb51.WriteString(preceding)
6365
}
6466
toDecode := encoded[unescapeIdx[0]+3 : unescapeIdx[1]-1]
6567
decodedBytes := make([]byte, len(toDecode)/2)
@@ -69,12 +71,14 @@ func decodeEnvSectionKey(encoded string) (ok bool, section, key string) {
6971
decodedBytes[i] = byte(byteInt)
7072
}
7173
if inKey {
72-
key += string(decodedBytes)
74+
keySb51.Write(decodedBytes)
7375
} else {
74-
section += string(decodedBytes)
76+
sectionSb51.Write(decodedBytes)
7577
}
7678
last = unescapeIdx[1]
7779
}
80+
key += keySb51.String()
81+
section += sectionSb51.String()
7882
remaining := encoded[last:]
7983
if !inKey {
8084
if splitter := strings.Index(remaining, "__"); splitter > -1 {

0 commit comments

Comments
 (0)