Skip to content

Commit 1e33007

Browse files
committed
Fix final 2 lint issues: goconst and gosec
GOCONST FIX: - pkg/obcache/cache_redis_test.go: Create testKeyConst constant to avoid repeated string literal 'test-key' when testKey variable already exists GOSEC FIX: - pkg/obcache/hooks_test.go: Fix G115 integer overflow by making numGoroutines and numOperations constants and computing multiplication before int32 conversion to avoid overflow during cast All golangci-lint issues now resolved.
1 parent 72d033e commit 1e33007

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

pkg/obcache/cache_redis_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"github.com/redis/go-redis/v9"
99
)
1010

11+
const testKeyConst = "test-key"
12+
1113
func TestCacheWithRedisStore(t *testing.T) {
1214
// Create a Redis client
1315
client := redis.NewClient(&redis.Options{
@@ -39,7 +41,7 @@ func TestCacheWithRedisStore(t *testing.T) {
3941
defer func() { _ = cache.Close() }()
4042

4143
// Test basic operations
42-
testKey := "test-key"
44+
testKey := testKeyConst
4345
testValue := "test-value"
4446

4547
// Test Set

pkg/obcache/hooks_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ func TestHookConcurrency(t *testing.T) {
170170

171171
// Concurrent cache operations to trigger hooks
172172
var wg sync.WaitGroup
173-
numGoroutines := 50
174-
numOperations := 100
173+
const numGoroutines = 50
174+
const numOperations = 100
175175

176176
wg.Add(numGoroutines)
177177
for i := 0; i < numGoroutines; i++ {
@@ -191,7 +191,7 @@ func TestHookConcurrency(t *testing.T) {
191191

192192
wg.Wait()
193193

194-
expectedCalls := int32(numGoroutines) * int32(numOperations)
194+
expectedCalls := int32(numGoroutines * numOperations)
195195
actualCalls := atomic.LoadInt32(&hookCallCount)
196196

197197
if actualCalls != expectedCalls {

0 commit comments

Comments
 (0)