Skip to content

Commit 1cfb718

Browse files
authored
Update golangci-lint to v1.62.2, fix issues (#32845)
Update it and fix new issues related to `redefines-builtin-id`
1 parent 7616aeb commit 1cfb718

File tree

13 files changed

+36
-36
lines changed

13 files changed

+36
-36
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ XGO_VERSION := go-1.23.x
2828
AIR_PACKAGE ?= github.com/air-verse/air@v1
2929
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/[email protected]
3030
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
31-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.3
31+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3333
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]

models/issues/issue_index.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ func RecalculateIssueIndexForRepo(ctx context.Context, repoID int64) error {
1818
}
1919
defer committer.Close()
2020

21-
var max int64
22-
if _, err = db.GetEngine(ctx).Select(" MAX(`index`)").Table("issue").Where("repo_id=?", repoID).Get(&max); err != nil {
21+
var maxIndex int64
22+
if _, err = db.GetEngine(ctx).Select(" MAX(`index`)").Table("issue").Where("repo_id=?", repoID).Get(&maxIndex); err != nil {
2323
return err
2424
}
2525

26-
if err = db.SyncMaxResourceIndex(ctx, "issue_index", repoID, max); err != nil {
26+
if err = db.SyncMaxResourceIndex(ctx, "issue_index", repoID, maxIndex); err != nil {
2727
return err
2828
}
2929

modules/auth/password/password.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ func IsComplexEnough(pwd string) bool {
9999
func Generate(n int) (string, error) {
100100
NewComplexity()
101101
buffer := make([]byte, n)
102-
max := big.NewInt(int64(len(validChars)))
102+
maxInt := big.NewInt(int64(len(validChars)))
103103
for {
104104
for j := 0; j < n; j++ {
105-
rnd, err := rand.Int(rand.Reader, max)
105+
rnd, err := rand.Int(rand.Reader, maxInt)
106106
if err != nil {
107107
return "", err
108108
}

modules/git/repo_commit.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,15 @@ func (repo *Repository) getBranches(env []string, commitID string, limit int) ([
465465

466466
refs := strings.Split(stdout, "\n")
467467

468-
var max int
468+
var maxNum int
469469
if len(refs) > limit {
470-
max = limit
470+
maxNum = limit
471471
} else {
472-
max = len(refs) - 1
472+
maxNum = len(refs) - 1
473473
}
474474

475-
branches := make([]string, max)
476-
for i, ref := range refs[:max] {
475+
branches := make([]string, maxNum)
476+
for i, ref := range refs[:maxNum] {
477477
parts := strings.Fields(ref)
478478

479479
branches[i] = parts[len(parts)-1]

modules/graceful/manager.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@ func (g *Manager) ServerDone() {
218218
g.runningServerWaitGroup.Done()
219219
}
220220

221-
func (g *Manager) setStateTransition(old, new state) bool {
221+
func (g *Manager) setStateTransition(oldState, newState state) bool {
222222
g.lock.Lock()
223-
if g.state != old {
223+
if g.state != oldState {
224224
g.lock.Unlock()
225225
return false
226226
}
227-
g.state = new
227+
g.state = newState
228228
g.lock.Unlock()
229229
return true
230230
}

modules/indexer/internal/bleve/query.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ func BoolFieldQuery(value bool, field string) *query.BoolFieldQuery {
3535
return q
3636
}
3737

38-
func NumericRangeInclusiveQuery(min, max optional.Option[int64], field string) *query.NumericRangeQuery {
38+
func NumericRangeInclusiveQuery(minOption, maxOption optional.Option[int64], field string) *query.NumericRangeQuery {
3939
var minF, maxF *float64
4040
var minI, maxI *bool
41-
if min.Has() {
41+
if minOption.Has() {
4242
minF = new(float64)
43-
*minF = float64(min.Value())
43+
*minF = float64(minOption.Value())
4444
minI = new(bool)
4545
*minI = true
4646
}
47-
if max.Has() {
47+
if maxOption.Has() {
4848
maxF = new(float64)
49-
*maxF = float64(max.Value())
49+
*maxF = float64(maxOption.Value())
5050
maxI = new(bool)
5151
*maxI = true
5252
}

modules/indexer/internal/paginator.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import (
1010
)
1111

1212
// ParsePaginator parses a db.Paginator into a skip and limit
13-
func ParsePaginator(paginator *db.ListOptions, max ...int) (int, int) {
13+
func ParsePaginator(paginator *db.ListOptions, maxNums ...int) (int, int) {
1414
// Use a very large number to indicate no limit
1515
unlimited := math.MaxInt32
16-
if len(max) > 0 {
16+
if len(maxNums) > 0 {
1717
// Some indexer engines have a limit on the page size, respect that
18-
unlimited = max[0]
18+
unlimited = maxNums[0]
1919
}
2020

2121
if paginator == nil || paginator.IsListAll() {

modules/log/event_format.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ func EventFormatTextMessage(mode *WriterMode, event *Event, msgFormat string, ms
110110
buf = append(buf, ' ')
111111
}
112112
if flags&(Ltime|Lmicroseconds) != 0 {
113-
hour, min, sec := t.Clock()
113+
hour, minNum, sec := t.Clock()
114114
buf = itoa(buf, hour, 2)
115115
buf = append(buf, ':')
116-
buf = itoa(buf, min, 2)
116+
buf = itoa(buf, minNum, 2)
117117
buf = append(buf, ':')
118118
buf = itoa(buf, sec, 2)
119119
if flags&Lmicroseconds != 0 {

modules/references/references.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ func newKeywords() {
164164
})
165165
}
166166

167-
func doNewKeywords(close, reopen []string) {
168-
issueCloseKeywordsPat = makeKeywordsPat(close)
169-
issueReopenKeywordsPat = makeKeywordsPat(reopen)
167+
func doNewKeywords(closeKeywords, reopenKeywords []string) {
168+
issueCloseKeywordsPat = makeKeywordsPat(closeKeywords)
169+
issueReopenKeywordsPat = makeKeywordsPat(reopenKeywords)
170170
}
171171

172172
// getGiteaHostName returns a normalized string with the local host name, with no scheme or port information

modules/templates/util_date.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func parseLegacy(datetime string) time.Time {
5353
return t
5454
}
5555

56-
func anyToTime(any any) (t time.Time, isZero bool) {
57-
switch v := any.(type) {
56+
func anyToTime(value any) (t time.Time, isZero bool) {
57+
switch v := value.(type) {
5858
case nil:
5959
// it is zero
6060
case *time.Time:
@@ -72,7 +72,7 @@ func anyToTime(any any) (t time.Time, isZero bool) {
7272
case int64:
7373
t = timeutil.TimeStamp(v).AsTime()
7474
default:
75-
panic(fmt.Sprintf("Unsupported time type %T", any))
75+
panic(fmt.Sprintf("Unsupported time type %T", value))
7676
}
7777
return t, t.IsZero() || t.Unix() == 0
7878
}

modules/templates/util_string.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func (su *StringUtils) Cut(s, sep string) []any {
5353
return []any{before, after, found}
5454
}
5555

56-
func (su *StringUtils) EllipsisString(s string, max int) string {
57-
return base.EllipsisString(s, max)
56+
func (su *StringUtils) EllipsisString(s string, maxLength int) string {
57+
return base.EllipsisString(s, maxLength)
5858
}
5959

6060
func (su *StringUtils) ToUpper(s string) string {

routers/api/v1/repo/issue_dependency.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ func GetIssueBlocks(ctx *context.APIContext) {
338338
}
339339

340340
skip := (page - 1) * limit
341-
max := page * limit
341+
maxNum := page * limit
342342

343343
deps, err := issue.BlockingDependencies(ctx)
344344
if err != nil {
@@ -352,7 +352,7 @@ func GetIssueBlocks(ctx *context.APIContext) {
352352
repoPerms[ctx.Repo.Repository.ID] = ctx.Repo.Permission
353353

354354
for i, depMeta := range deps {
355-
if i < skip || i >= max {
355+
if i < skip || i >= maxNum {
356356
continue
357357
}
358358

routers/api/v1/repo/wiki.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ func ListWikiPages(ctx *context.APIContext) {
308308
}
309309

310310
skip := (page - 1) * limit
311-
max := page * limit
311+
maxNum := page * limit
312312

313313
entries, err := commit.ListEntries()
314314
if err != nil {
@@ -317,7 +317,7 @@ func ListWikiPages(ctx *context.APIContext) {
317317
}
318318
pages := make([]*api.WikiPageMetaData, 0, len(entries))
319319
for i, entry := range entries {
320-
if i < skip || i >= max || !entry.IsRegular() {
320+
if i < skip || i >= maxNum || !entry.IsRegular() {
321321
continue
322322
}
323323
c, err := wikiRepo.GetCommitByPath(entry.Name())

0 commit comments

Comments
 (0)