Skip to content

Commit 08e5f11

Browse files
authored
Enable the revive 'redefines-builtin-id' rule (#1230)
1 parent d15675c commit 08e5f11

File tree

7 files changed

+15
-24
lines changed

7 files changed

+15
-24
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ linters:
108108
- { disabled: true, name: max-public-structs }
109109
- { disabled: true, name: nested-structs }
110110
- { disabled: true, name: package-comments }
111-
- { disabled: true, name: redefines-builtin-id }
112111
- { disabled: true, name: unchecked-type-assertion }
113112
- { disabled: true, name: unexported-naming }
114113
- { disabled: true, name: unexported-return }
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package utils
22

3-
func SubstringMax(s string, max int) string {
4-
if len(s) <= max {
3+
func SubstringMax(s string, maxLen int) string {
4+
if len(s) <= maxLen {
55
return s
66
}
7-
return s[:max] + "..."
7+
return s[:maxLen] + "..."
88
}

packages/orchestrator/internal/sandbox/build/build.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ func NewFile(
3737
}
3838
}
3939

40-
func min(a, b int64) int64 {
41-
if a < b {
42-
return a
43-
}
44-
45-
return b
46-
}
47-
4840
func (b *File) ReadAt(ctx context.Context, p []byte, off int64) (n int, err error) {
4941
for n < len(p) {
5042
mappedOffset, mappedLength, buildID, err := b.header.GetShiftedMapping(off + int64(n))

packages/orchestrator/internal/sandbox/uffd/userfaultfd/constants.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ func NewUffdioRegister(start, length, mode CULong) UffdioRegister {
7676
}
7777
}
7878

79-
func NewUffdioCopy(b []byte, address CULong, pagesize CULong, mode CULong, copy CLong) UffdioCopy {
79+
func NewUffdioCopy(b []byte, address CULong, pagesize CULong, mode CULong, bytesCopied CLong) UffdioCopy {
8080
return UffdioCopy{
8181
src: CULong(uintptr(unsafe.Pointer(&b[0]))),
8282
dst: address &^ (pagesize - 1),
8383
len: pagesize,
8484
mode: mode,
85-
copy: copy,
85+
copy: bytesCopied,
8686
}
8787
}
8888

packages/shared/pkg/storage/gcp_multipart.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ func createRetryableClient(config RetryConfig) *retryablehttp.Client {
5252
client.RetryWaitMax = config.MaxBackoff
5353

5454
// Custom backoff function with full jitter to avoid thundering herd
55-
client.Backoff = func(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration {
55+
client.Backoff = func(start, maxBackoff time.Duration, attemptNum int, resp *http.Response) time.Duration {
5656
// Calculate exponential backoff
57-
backoff := min
57+
backoff := start
5858
for range attemptNum {
5959
backoff = time.Duration(float64(backoff) * config.BackoffMultiplier)
60-
if backoff > max {
61-
backoff = max
60+
if backoff > maxBackoff {
61+
backoff = maxBackoff
6262
break
6363
}
6464
}

packages/shared/pkg/storage/gcp_multipart_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ func TestMultipartUploader_HighConcurrency_StressTest(t *testing.T) {
285285

286286
// Update max concurrent parts
287287
for {
288-
max := atomic.LoadInt32(&maxConcurrentParts)
289-
if current <= max || atomic.CompareAndSwapInt32(&maxConcurrentParts, max, current) {
288+
maxConcurrent := atomic.LoadInt32(&maxConcurrentParts)
289+
if current <= maxConcurrent || atomic.CompareAndSwapInt32(&maxConcurrentParts, maxConcurrent, current) {
290290
break
291291
}
292292
}
@@ -564,8 +564,8 @@ func TestMultipartUploader_ResourceExhaustion_TooManyConcurrentUploads(t *testin
564564

565565
// Track max observed concurrency
566566
for {
567-
max := atomic.LoadInt32(&maxObservedConcurrency)
568-
if current <= max || atomic.CompareAndSwapInt32(&maxObservedConcurrency, max, current) {
567+
maxObserved := atomic.LoadInt32(&maxObservedConcurrency)
568+
if current <= maxObserved || atomic.CompareAndSwapInt32(&maxObservedConcurrency, maxObserved, current) {
569569
break
570570
}
571571
}

packages/shared/pkg/storage/storage_cache.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,8 @@ func (c *CachedFileObjectProvider) readAndCacheFullRemoteFile(ctx context.Contex
399399
return int64(written), err
400400
}
401401

402-
func cleanup(msg string, close func() error) {
403-
if err := close(); err != nil {
402+
func cleanup(msg string, fn func() error) {
403+
if err := fn(); err != nil {
404404
zap.L().Warn(msg, zap.Error(err))
405405
}
406406
}

0 commit comments

Comments
 (0)