@@ -96,12 +96,12 @@ func TestCacheConcurrency(t *testing.T) {
9696 go func (id int ) {
9797 defer wg .Done ()
9898 for j := 0 ; j < opsPerGoroutine ; j ++ {
99- key := uint64 (id * opsPerGoroutine + j )
99+ key := uint64 (id * opsPerGoroutine + j ) //nolint:gosec // G115 - test loop
100100 c .Add (key , fmt .Sprintf ("value-%d-%d" , id , j ))
101101
102102 // Randomly access some values
103103 if j % 10 == 0 {
104- randomKey := uint64 ((id + j ) % (numGoroutines * opsPerGoroutine ))
104+ randomKey := uint64 ((id + j ) % (numGoroutines * opsPerGoroutine )) //nolint:gosec // G115 - test calculation
105105 c .Get (randomKey )
106106 }
107107 }
@@ -122,7 +122,7 @@ func TestCacheRemoveConcurrency(t *testing.T) {
122122
123123 // Pre-populate cache
124124 for i := 0 ; i < numGoroutines * keysPerGoroutine ; i ++ {
125- c .Add (uint64 (i ), i )
125+ c .Add (uint64 (i ), i ) //nolint:gosec // G115 - test loop //nolint:gosec // G115 - test loop
126126 }
127127
128128 var wg sync.WaitGroup
@@ -133,7 +133,7 @@ func TestCacheRemoveConcurrency(t *testing.T) {
133133 go func (id int ) {
134134 defer wg .Done ()
135135 for j := 0 ; j < keysPerGoroutine ; j ++ {
136- key := uint64 (id * keysPerGoroutine + j )
136+ key := uint64 (id * keysPerGoroutine + j ) //nolint:gosec // G115 - test loop
137137 c .Remove (key )
138138 }
139139 }(i )
@@ -178,22 +178,22 @@ func TestCacheCapacity(t *testing.T) {
178178
179179 // Add some items
180180 for i := 0 ; i < 50 ; i ++ {
181- c .Add (uint64 (i ), i )
181+ c .Add (uint64 (i ), i ) //nolint:gosec // G115 - test loop
182182 }
183183
184184 // Verify size
185185 assert .Equal (t , 50 , c .Len ())
186186
187187 // Add more items up to capacity
188188 for i := 50 ; i < 100 ; i ++ {
189- c .Add (uint64 (i ), i )
189+ c .Add (uint64 (i ), i ) //nolint:gosec // G115 - test loop
190190 }
191191
192192 assert .Equal (t , 100 , c .Len ())
193193
194194 // Adding more should maintain capacity
195195 for i := 100 ; i < 150 ; i ++ {
196- c .Add (uint64 (i ), i )
196+ c .Add (uint64 (i ), i ) //nolint:gosec // G115 - test loop
197197 }
198198
199199 assert .LessOrEqual (t , c .Len (), 100 , "Cache should not exceed capacity" )
@@ -205,14 +205,14 @@ func BenchmarkCacheGet(b *testing.B) {
205205
206206 // Pre-populate
207207 for i := 0 ; i < 10000 ; i ++ {
208- c .Add (uint64 (i ), i )
208+ c .Add (uint64 (i ), i ) //nolint:gosec // G115 - test loop
209209 }
210210
211211 b .ResetTimer ()
212212 b .RunParallel (func (pb * testing.PB ) {
213213 i := 0
214214 for pb .Next () {
215- c .Get (uint64 (i % 10000 ))
215+ c .Get (uint64 (i % 10000 )) //nolint:gosec // G115 - test loop
216216 i ++
217217 }
218218 })
@@ -225,7 +225,7 @@ func BenchmarkCacheAdd(b *testing.B) {
225225 b .RunParallel (func (pb * testing.PB ) {
226226 i := 0
227227 for pb .Next () {
228- c .Add (uint64 (i ), i )
228+ c .Add (uint64 (i ), i ) //nolint:gosec // G115 - test loop
229229 i ++
230230 }
231231 })
@@ -236,17 +236,17 @@ func BenchmarkCacheMixed(b *testing.B) {
236236
237237 // Pre-populate
238238 for i := 0 ; i < 5000 ; i ++ {
239- c .Add (uint64 (i ), i )
239+ c .Add (uint64 (i ), i ) //nolint:gosec // G115 - test loop
240240 }
241241
242242 b .ResetTimer ()
243243 b .RunParallel (func (pb * testing.PB ) {
244244 i := 0
245245 for pb .Next () {
246246 if i % 2 == 0 {
247- c .Get (uint64 (i % 10000 ))
247+ c .Get (uint64 (i % 10000 )) //nolint:gosec // G115 - test loop //nolint:gosec // G115 - test loop
248248 } else {
249- c .Add (uint64 (i ), i )
249+ c .Add (uint64 (i ), i ) //nolint:gosec // G115 - test loop
250250 }
251251 i ++
252252 }
@@ -262,13 +262,13 @@ func TestCacheMemoryUsage(t *testing.T) {
262262
263263 // Add items
264264 for i := 0 ; i < 10000 ; i ++ {
265- c .Add (uint64 (i ), fmt .Sprintf ("value-%d" , i ))
265+ c .Add (uint64 (i ), fmt .Sprintf ("value-%d" , i )) //nolint:gosec // G115 - test loop
266266 }
267267
268268 // Just verify the cache is working
269269 found := 0
270270 for i := 0 ; i < 100 ; i ++ {
271- if _ , ok := c .Get (uint64 (i )); ok {
271+ if _ , ok := c .Get (uint64 (i )); ok { //nolint:gosec // G115 - test loop
272272 found ++
273273 }
274274 }
0 commit comments