Skip to content

Commit cb82817

Browse files
authored
chore: configure copyloopvar and intrange linters (#7675)
1 parent b96d3af commit cb82817

File tree

33 files changed

+100
-100
lines changed

33 files changed

+100
-100
lines changed

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ linters:
77
enable:
88
- asasalint
99
- bodyclose
10+
- copyloopvar
1011
- depguard
1112
- errcheck
1213
- errorlint
@@ -15,6 +16,7 @@ linters:
1516
- gosec
1617
- govet
1718
- ineffassign
19+
- intrange
1820
- misspell
1921
- perfsprint
2022
- revive

bridges/otellogr/bench_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func BenchmarkLogSink(b *testing.B) {
2828

2929
b.ReportAllocs()
3030
b.ResetTimer()
31-
for n := 0; n < b.N; n++ {
31+
for n := range b.N {
3232
logSinks[n].Info(0, message, keyValues...)
3333
}
3434
})
@@ -41,7 +41,7 @@ func BenchmarkLogSink(b *testing.B) {
4141

4242
b.ReportAllocs()
4343
b.ResetTimer()
44-
for n := 0; n < b.N; n++ {
44+
for n := range b.N {
4545
logSinks[n].Error(err, message, keyValues...)
4646
}
4747
})
@@ -54,7 +54,7 @@ func BenchmarkLogSink(b *testing.B) {
5454

5555
b.ReportAllocs()
5656
b.ResetTimer()
57-
for n := 0; n < b.N; n++ {
57+
for n := range b.N {
5858
logSinks[n].WithValues(keyValues...)
5959
}
6060
})
@@ -67,7 +67,7 @@ func BenchmarkLogSink(b *testing.B) {
6767

6868
b.ReportAllocs()
6969
b.ResetTimer()
70-
for n := 0; n < b.N; n++ {
70+
for n := range b.N {
7171
logSinks[n].WithName("name")
7272
}
7373
})
@@ -80,7 +80,7 @@ func BenchmarkLogSink(b *testing.B) {
8080

8181
b.ReportAllocs()
8282
b.ResetTimer()
83-
for n := 0; n < b.N; n++ {
83+
for n := range b.N {
8484
logSinks[n].WithName("name").WithValues(keyValues...)
8585
}
8686
})
@@ -93,7 +93,7 @@ func BenchmarkLogSink(b *testing.B) {
9393

9494
b.ReportAllocs()
9595
b.ResetTimer()
96-
for n := 0; n < b.N; n++ {
96+
for n := range b.N {
9797
logSinks[n].Info(0, message)
9898
}
9999
})

bridges/otellogrus/bench_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func BenchmarkHook(b *testing.B) {
3131

3232
b.ReportAllocs()
3333
b.ResetTimer()
34-
for n := 0; n < b.N; n++ {
34+
for n := range b.N {
3535
_ = hooks[n].Fire(record)
3636
}
3737
})

bridges/otelslog/bench_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func BenchmarkHandler(b *testing.B) {
4040

4141
b.ReportAllocs()
4242
b.ResetTimer()
43-
for n := 0; n < b.N; n++ {
43+
for n := range b.N {
4444
err = handlers[n].Handle(ctx, record)
4545
}
4646
})
@@ -54,7 +54,7 @@ func BenchmarkHandler(b *testing.B) {
5454

5555
b.ReportAllocs()
5656
b.ResetTimer()
57-
for n := 0; n < b.N; n++ {
57+
for n := range b.N {
5858
h = handlers[n].WithAttrs(attrs5)
5959
}
6060
})
@@ -66,7 +66,7 @@ func BenchmarkHandler(b *testing.B) {
6666

6767
b.ReportAllocs()
6868
b.ResetTimer()
69-
for n := 0; n < b.N; n++ {
69+
for n := range b.N {
7070
h = handlers[n].WithAttrs(attrs10)
7171
}
7272
})
@@ -80,7 +80,7 @@ func BenchmarkHandler(b *testing.B) {
8080

8181
b.ReportAllocs()
8282
b.ResetTimer()
83-
for n := 0; n < b.N; n++ {
83+
for n := range b.N {
8484
h = handlers[n].WithGroup("group")
8585
}
8686
})
@@ -94,7 +94,7 @@ func BenchmarkHandler(b *testing.B) {
9494

9595
b.ReportAllocs()
9696
b.ResetTimer()
97-
for n := 0; n < b.N; n++ {
97+
for n := range b.N {
9898
h = handlers[n].WithGroup("group").WithAttrs(attrs5)
9999
}
100100
})
@@ -106,7 +106,7 @@ func BenchmarkHandler(b *testing.B) {
106106

107107
b.ReportAllocs()
108108
b.ResetTimer()
109-
for n := 0; n < b.N; n++ {
109+
for n := range b.N {
110110
h = handlers[n].WithGroup("group").WithAttrs(attrs10)
111111
}
112112
})
@@ -121,7 +121,7 @@ func BenchmarkHandler(b *testing.B) {
121121

122122
b.ReportAllocs()
123123
b.ResetTimer()
124-
for n := 0; n < b.N; n++ {
124+
for n := range b.N {
125125
err = handlers[n].Handle(ctx, record)
126126
}
127127
})
@@ -133,7 +133,7 @@ func BenchmarkHandler(b *testing.B) {
133133

134134
b.ReportAllocs()
135135
b.ResetTimer()
136-
for n := 0; n < b.N; n++ {
136+
for n := range b.N {
137137
err = handlers[n].Handle(ctx, record)
138138
}
139139
})
@@ -147,7 +147,7 @@ func BenchmarkHandler(b *testing.B) {
147147

148148
b.ReportAllocs()
149149
b.ResetTimer()
150-
for n := 0; n < b.N; n++ {
150+
for n := range b.N {
151151
err = handlers[n].Handle(ctx, record)
152152
}
153153
})

bridges/otelzap/encoder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ type turduckens int
362362
func (t turduckens) MarshalLogArray(enc zapcore.ArrayEncoder) error {
363363
var err error
364364
tur := turducken{}
365-
for i := 0; i < int(t); i++ {
365+
for range t {
366366
err = errors.Join(err, enc.AppendObject(tur))
367367
}
368368
return err

bridges/prometheus/producer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ func convertExponentialBuckets(bucketSpans []*dto.BucketSpan, deltas []int64) me
230230
// Increase the count index by the Offset to insert Offset zeroes
231231
countIndex += bs.GetOffset()
232232
}
233-
for j := uint32(0); j < bs.GetLength(); j++ {
233+
for range bs.GetLength() {
234234
// Convert deltas to the cumulative number of observations
235235
count += deltas[deltaIndex]
236236
deltaIndex++

instrumentation/github.com/aws/aws-lambda-go/otellambda/lambda_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ func BenchmarkInstrumentHandler(b *testing.B) {
266266
args := []reflect.Value{ctx, payload}
267267

268268
b.ResetTimer()
269-
for i := 0; i < b.N; i++ {
269+
for range b.N {
270270
wrappedCallable.Call(args)
271271
}
272272
}
@@ -277,7 +277,7 @@ func BenchmarkWrapHandler(b *testing.B) {
277277
wrapped := WrapHandler(emptyHandler{})
278278

279279
b.ResetTimer()
280-
for i := 0; i < b.N; i++ {
280+
for range b.N {
281281
_, _ = wrapped.Invoke(mockContext, []byte{0})
282282
}
283283
}

instrumentation/github.com/emicklei/go-restful/otelrestful/internal/semconv/bench_test.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

instrumentation/github.com/emicklei/go-restful/otelrestful/internal/semconv/env_test.go

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

instrumentation/github.com/gin-gonic/gin/otelgin/internal/semconv/bench_test.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)