diff options
author | silverwind <me@silverwind.io> | 2024-12-15 03:31:07 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-15 02:31:07 +0000 |
commit | 1cfb718976e2db517da0e76bda835edd9df1fabd (patch) | |
tree | 556f0e895ce6d6f35d57266ea9c51e68c7f89ce6 /modules | |
parent | 7616aeb2ea2a02c15480dcd4a232e98081569690 (diff) | |
download | gitea-1cfb718976e2db517da0e76bda835edd9df1fabd.tar.gz gitea-1cfb718976e2db517da0e76bda835edd9df1fabd.zip |
Update golangci-lint to v1.62.2, fix issues (#32845)
Update it and fix new issues related to `redefines-builtin-id`
Diffstat (limited to 'modules')
-rw-r--r-- | modules/auth/password/password.go | 4 | ||||
-rw-r--r-- | modules/git/repo_commit.go | 10 | ||||
-rw-r--r-- | modules/graceful/manager.go | 6 | ||||
-rw-r--r-- | modules/indexer/internal/bleve/query.go | 10 | ||||
-rw-r--r-- | modules/indexer/internal/paginator.go | 6 | ||||
-rw-r--r-- | modules/log/event_format.go | 4 | ||||
-rw-r--r-- | modules/references/references.go | 6 | ||||
-rw-r--r-- | modules/templates/util_date.go | 6 | ||||
-rw-r--r-- | modules/templates/util_string.go | 4 |
9 files changed, 28 insertions, 28 deletions
diff --git a/modules/auth/password/password.go b/modules/auth/password/password.go index 85f9780709..c66b62937f 100644 --- a/modules/auth/password/password.go +++ b/modules/auth/password/password.go @@ -99,10 +99,10 @@ func IsComplexEnough(pwd string) bool { func Generate(n int) (string, error) { NewComplexity() buffer := make([]byte, n) - max := big.NewInt(int64(len(validChars))) + maxInt := big.NewInt(int64(len(validChars))) for { for j := 0; j < n; j++ { - rnd, err := rand.Int(rand.Reader, max) + rnd, err := rand.Int(rand.Reader, maxInt) if err != nil { return "", err } diff --git a/modules/git/repo_commit.go b/modules/git/repo_commit.go index 9405634df1..9ffadb833d 100644 --- a/modules/git/repo_commit.go +++ b/modules/git/repo_commit.go @@ -465,15 +465,15 @@ func (repo *Repository) getBranches(env []string, commitID string, limit int) ([ refs := strings.Split(stdout, "\n") - var max int + var maxNum int if len(refs) > limit { - max = limit + maxNum = limit } else { - max = len(refs) - 1 + maxNum = len(refs) - 1 } - branches := make([]string, max) - for i, ref := range refs[:max] { + branches := make([]string, maxNum) + for i, ref := range refs[:maxNum] { parts := strings.Fields(ref) branches[i] = parts[len(parts)-1] diff --git a/modules/graceful/manager.go b/modules/graceful/manager.go index 3f1115066a..991b2f2b7a 100644 --- a/modules/graceful/manager.go +++ b/modules/graceful/manager.go @@ -218,13 +218,13 @@ func (g *Manager) ServerDone() { g.runningServerWaitGroup.Done() } -func (g *Manager) setStateTransition(old, new state) bool { +func (g *Manager) setStateTransition(oldState, newState state) bool { g.lock.Lock() - if g.state != old { + if g.state != oldState { g.lock.Unlock() return false } - g.state = new + g.state = newState g.lock.Unlock() return true } diff --git a/modules/indexer/internal/bleve/query.go b/modules/indexer/internal/bleve/query.go index 21422b281c..1b18ca1a77 100644 --- a/modules/indexer/internal/bleve/query.go +++ b/modules/indexer/internal/bleve/query.go @@ -35,18 +35,18 @@ func BoolFieldQuery(value bool, field string) *query.BoolFieldQuery { return q } -func NumericRangeInclusiveQuery(min, max optional.Option[int64], field string) *query.NumericRangeQuery { +func NumericRangeInclusiveQuery(minOption, maxOption optional.Option[int64], field string) *query.NumericRangeQuery { var minF, maxF *float64 var minI, maxI *bool - if min.Has() { + if minOption.Has() { minF = new(float64) - *minF = float64(min.Value()) + *minF = float64(minOption.Value()) minI = new(bool) *minI = true } - if max.Has() { + if maxOption.Has() { maxF = new(float64) - *maxF = float64(max.Value()) + *maxF = float64(maxOption.Value()) maxI = new(bool) *maxI = true } diff --git a/modules/indexer/internal/paginator.go b/modules/indexer/internal/paginator.go index ee204bf047..f1e19740eb 100644 --- a/modules/indexer/internal/paginator.go +++ b/modules/indexer/internal/paginator.go @@ -10,12 +10,12 @@ import ( ) // ParsePaginator parses a db.Paginator into a skip and limit -func ParsePaginator(paginator *db.ListOptions, max ...int) (int, int) { +func ParsePaginator(paginator *db.ListOptions, maxNums ...int) (int, int) { // Use a very large number to indicate no limit unlimited := math.MaxInt32 - if len(max) > 0 { + if len(maxNums) > 0 { // Some indexer engines have a limit on the page size, respect that - unlimited = max[0] + unlimited = maxNums[0] } if paginator == nil || paginator.IsListAll() { diff --git a/modules/log/event_format.go b/modules/log/event_format.go index d9dbebf831..0b8d1cec79 100644 --- a/modules/log/event_format.go +++ b/modules/log/event_format.go @@ -110,10 +110,10 @@ func EventFormatTextMessage(mode *WriterMode, event *Event, msgFormat string, ms buf = append(buf, ' ') } if flags&(Ltime|Lmicroseconds) != 0 { - hour, min, sec := t.Clock() + hour, minNum, sec := t.Clock() buf = itoa(buf, hour, 2) buf = append(buf, ':') - buf = itoa(buf, min, 2) + buf = itoa(buf, minNum, 2) buf = append(buf, ':') buf = itoa(buf, sec, 2) if flags&Lmicroseconds != 0 { diff --git a/modules/references/references.go b/modules/references/references.go index 2889430bcf..6e549cb875 100644 --- a/modules/references/references.go +++ b/modules/references/references.go @@ -164,9 +164,9 @@ func newKeywords() { }) } -func doNewKeywords(close, reopen []string) { - issueCloseKeywordsPat = makeKeywordsPat(close) - issueReopenKeywordsPat = makeKeywordsPat(reopen) +func doNewKeywords(closeKeywords, reopenKeywords []string) { + issueCloseKeywordsPat = makeKeywordsPat(closeKeywords) + issueReopenKeywordsPat = makeKeywordsPat(reopenKeywords) } // getGiteaHostName returns a normalized string with the local host name, with no scheme or port information diff --git a/modules/templates/util_date.go b/modules/templates/util_date.go index 66f83d23fe..658691ee40 100644 --- a/modules/templates/util_date.go +++ b/modules/templates/util_date.go @@ -53,8 +53,8 @@ func parseLegacy(datetime string) time.Time { return t } -func anyToTime(any any) (t time.Time, isZero bool) { - switch v := any.(type) { +func anyToTime(value any) (t time.Time, isZero bool) { + switch v := value.(type) { case nil: // it is zero case *time.Time: @@ -72,7 +72,7 @@ func anyToTime(any any) (t time.Time, isZero bool) { case int64: t = timeutil.TimeStamp(v).AsTime() default: - panic(fmt.Sprintf("Unsupported time type %T", any)) + panic(fmt.Sprintf("Unsupported time type %T", value)) } return t, t.IsZero() || t.Unix() == 0 } diff --git a/modules/templates/util_string.go b/modules/templates/util_string.go index 479b755da1..2ae27d0833 100644 --- a/modules/templates/util_string.go +++ b/modules/templates/util_string.go @@ -53,8 +53,8 @@ func (su *StringUtils) Cut(s, sep string) []any { return []any{before, after, found} } -func (su *StringUtils) EllipsisString(s string, max int) string { - return base.EllipsisString(s, max) +func (su *StringUtils) EllipsisString(s string, maxLength int) string { + return base.EllipsisString(s, maxLength) } func (su *StringUtils) ToUpper(s string) string { |