Skip to content

Commit

Permalink
ci: bump golangcilinter to 1.63.3 (#2707)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksraiden authored Jan 3, 2025
1 parent 1d93345 commit a3ae11b
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 59 deletions.
2 changes: 1 addition & 1 deletion tests/gocase/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ linters:
- bodyclose
- durationcheck
- errcheck
- exportloopref
- copyloopvar
- gofmt
- goimports
- gosimple
Expand Down
14 changes: 7 additions & 7 deletions tests/gocase/unit/type/bitmap/bitmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,13 +534,13 @@ func TestBitmap(t *testing.T) {

t.Run("BITPOS bit=1 fuzzy testing using SETBIT", func(t *testing.T) {
require.NoError(t, rdb.Del(ctx, "str").Err())
var max int64 = 524288
var maxInt int64 = 524288
var firstOnePos int64 = -1
for j := 0; j < 1000; j++ {
cmd := rdb.BitPosSpan(ctx, "str", 1, 0, -1, "bit")
require.NoError(t, cmd.Err())
require.EqualValues(t, firstOnePos, cmd.Val())
pos := util.RandomInt(max)
pos := util.RandomInt(maxInt)
require.NoError(t, rdb.SetBit(ctx, "str", int64(pos), 1).Err())
if firstOnePos == -1 || firstOnePos > pos {
firstOnePos = pos
Expand All @@ -549,18 +549,18 @@ func TestBitmap(t *testing.T) {
})

t.Run("BITPOS bit=0 fuzzy testing using SETBIT", func(t *testing.T) {
var max int64 = 524288
firstZeroPos := max
require.NoError(t, rdb.Set(ctx, "str", strings.Repeat("\xff", int(max/8)), 0).Err())
var maxInt int64 = 524288
firstZeroPos := maxInt
require.NoError(t, rdb.Set(ctx, "str", strings.Repeat("\xff", int(maxInt/8)), 0).Err())
for j := 0; j < 1000; j++ {
cmd := rdb.BitPosSpan(ctx, "str", 0, 0, -1, "bit")
require.NoError(t, cmd.Err())
if firstZeroPos == max {
if firstZeroPos == maxInt {
require.EqualValues(t, -1, cmd.Val())
} else {
require.EqualValues(t, firstZeroPos, cmd.Val())
}
pos := util.RandomInt(max)
pos := util.RandomInt(maxInt)
require.NoError(t, rdb.SetBit(ctx, "str", int64(pos), 0).Err())
if firstZeroPos > pos {
firstZeroPos = pos
Expand Down
4 changes: 2 additions & 2 deletions tests/gocase/unit/type/list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -777,10 +777,10 @@ func testList(t *testing.T, configs util.KvrocksServerConfigs) {
})

for listType, large := range largeValue {
trimList := func(listType string, min, max int64) []string {
trimList := func(listType string, minInt, maxInt int64) []string {
require.NoError(t, rdb.Del(ctx, "mylist").Err())
createList("mylist", []string{"1", "2", "3", "4", large})
require.NoError(t, rdb.LTrim(ctx, "mylist", min, max).Err())
require.NoError(t, rdb.LTrim(ctx, "mylist", minInt, maxInt).Err())
return rdb.LRange(ctx, "mylist", 0, -1).Val()
}

Expand Down
72 changes: 36 additions & 36 deletions tests/gocase/unit/type/zset/zset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -997,11 +997,11 @@ func basicTests(t *testing.T, rdb *redis.Client, ctx context.Context, enabledRES
})

t.Run("ZREMRANGEBYSCORE basics", func(t *testing.T) {
remrangebyscore := func(min, max string) int64 {
remrangebyscore := func(minStr, maxStr string) int64 {
createZset(rdb, ctx, "zset", []redis.Z{{1, "a"}, {2, "b"}, {3, "c"},
{4, "d"}, {5, "e"}})
require.Equal(t, int64(1), rdb.Exists(ctx, "zset").Val())
return rdb.ZRemRangeByScore(ctx, "zset", min, max).Val()
return rdb.ZRemRangeByScore(ctx, "zset", minStr, maxStr).Val()
}

// inner range
Expand Down Expand Up @@ -1060,11 +1060,11 @@ func basicTests(t *testing.T, rdb *redis.Client, ctx context.Context, enabledRES
})

t.Run("ZREMRANGEBYRANK basics", func(t *testing.T) {
remrangebyrank := func(min, max int64) int64 {
remrangebyrank := func(minInt, maxInt int64) int64 {
createZset(rdb, ctx, "zset", []redis.Z{{1, "a"}, {2, "b"}, {3, "c"},
{4, "d"}, {5, "e"}})
require.Equal(t, int64(1), rdb.Exists(ctx, "zset").Val())
return rdb.ZRemRangeByRank(ctx, "zset", min, max).Val()
return rdb.ZRemRangeByRank(ctx, "zset", minInt, maxInt).Val()
}

// inner range
Expand Down Expand Up @@ -1720,39 +1720,39 @@ func stressTests(t *testing.T, rdb *redis.Client, ctx context.Context, encoding
}

for i := 0; i < 100; i++ {
min, max := rand.Float64(), rand.Float64()
min, max = math.Min(min, max), math.Max(min, max)
low := rdb.ZRangeByScore(ctx, "zset", &redis.ZRangeBy{Min: "-inf", Max: fmt.Sprintf("%v", min)}).Val()
ok := rdb.ZRangeByScore(ctx, "zset", &redis.ZRangeBy{Min: fmt.Sprintf("%v", min), Max: fmt.Sprintf("%v", max)}).Val()
high := rdb.ZRangeByScore(ctx, "zset", &redis.ZRangeBy{Min: fmt.Sprintf("%v", max), Max: "+inf"}).Val()
lowEx := rdb.ZRangeByScore(ctx, "zset", &redis.ZRangeBy{Min: "-inf", Max: fmt.Sprintf("(%v", min)}).Val()
okEx := rdb.ZRangeByScore(ctx, "zset", &redis.ZRangeBy{Min: fmt.Sprintf("(%v", min), Max: fmt.Sprintf("(%v", max)}).Val()
highEx := rdb.ZRangeByScore(ctx, "zset", &redis.ZRangeBy{Min: fmt.Sprintf("(%v", max), Max: "+inf"}).Val()

require.Len(t, low, int(rdb.ZCount(ctx, "zset", "-inf", fmt.Sprintf("%v", min)).Val()))
require.Len(t, ok, int(rdb.ZCount(ctx, "zset", fmt.Sprintf("%v", min), fmt.Sprintf("%v", max)).Val()))
require.Len(t, high, int(rdb.ZCount(ctx, "zset", fmt.Sprintf("%v", max), "+inf").Val()))
require.Len(t, lowEx, int(rdb.ZCount(ctx, "zset", "-inf", fmt.Sprintf("(%v", min)).Val()))
require.Len(t, okEx, int(rdb.ZCount(ctx, "zset", fmt.Sprintf("(%v", min), fmt.Sprintf("(%v", max)).Val()))
require.Len(t, highEx, int(rdb.ZCount(ctx, "zset", fmt.Sprintf("(%v", max), "+inf").Val()))
minVal, maxVal := rand.Float64(), rand.Float64()
minVal, maxVal = math.Min(minVal, maxVal), math.Max(minVal, maxVal)
low := rdb.ZRangeByScore(ctx, "zset", &redis.ZRangeBy{Min: "-inf", Max: fmt.Sprintf("%v", minVal)}).Val()
ok := rdb.ZRangeByScore(ctx, "zset", &redis.ZRangeBy{Min: fmt.Sprintf("%v", minVal), Max: fmt.Sprintf("%v", maxVal)}).Val()
high := rdb.ZRangeByScore(ctx, "zset", &redis.ZRangeBy{Min: fmt.Sprintf("%v", maxVal), Max: "+inf"}).Val()
lowEx := rdb.ZRangeByScore(ctx, "zset", &redis.ZRangeBy{Min: "-inf", Max: fmt.Sprintf("(%v", minVal)}).Val()
okEx := rdb.ZRangeByScore(ctx, "zset", &redis.ZRangeBy{Min: fmt.Sprintf("(%v", minVal), Max: fmt.Sprintf("(%v", maxVal)}).Val()
highEx := rdb.ZRangeByScore(ctx, "zset", &redis.ZRangeBy{Min: fmt.Sprintf("(%v", maxVal), Max: "+inf"}).Val()

require.Len(t, low, int(rdb.ZCount(ctx, "zset", "-inf", fmt.Sprintf("%v", minVal)).Val()))
require.Len(t, ok, int(rdb.ZCount(ctx, "zset", fmt.Sprintf("%v", minVal), fmt.Sprintf("%v", maxVal)).Val()))
require.Len(t, high, int(rdb.ZCount(ctx, "zset", fmt.Sprintf("%v", maxVal), "+inf").Val()))
require.Len(t, lowEx, int(rdb.ZCount(ctx, "zset", "-inf", fmt.Sprintf("(%v", minVal)).Val()))
require.Len(t, okEx, int(rdb.ZCount(ctx, "zset", fmt.Sprintf("(%v", minVal), fmt.Sprintf("(%v", maxVal)).Val()))
require.Len(t, highEx, int(rdb.ZCount(ctx, "zset", fmt.Sprintf("(%v", maxVal), "+inf").Val()))

for _, x := range low {
require.LessOrEqual(t, rdb.ZScore(ctx, "zset", x).Val(), min)
require.LessOrEqual(t, rdb.ZScore(ctx, "zset", x).Val(), minVal)
}
for _, x := range lowEx {
require.Less(t, rdb.ZScore(ctx, "zset", x).Val(), min)
require.Less(t, rdb.ZScore(ctx, "zset", x).Val(), minVal)
}
for _, x := range ok {
util.BetweenValues(t, rdb.ZScore(ctx, "zset", x).Val(), min, max)
util.BetweenValues(t, rdb.ZScore(ctx, "zset", x).Val(), minVal, maxVal)
}
for _, x := range okEx {
util.BetweenValuesEx(t, rdb.ZScore(ctx, "zset", x).Val(), min, max)
util.BetweenValuesEx(t, rdb.ZScore(ctx, "zset", x).Val(), minVal, maxVal)
}
for _, x := range high {
require.GreaterOrEqual(t, rdb.ZScore(ctx, "zset", x).Val(), min)
require.GreaterOrEqual(t, rdb.ZScore(ctx, "zset", x).Val(), minVal)
}
for _, x := range highEx {
require.Greater(t, rdb.ZScore(ctx, "zset", x).Val(), min)
require.Greater(t, rdb.ZScore(ctx, "zset", x).Val(), minVal)
}
}
})
Expand All @@ -1770,14 +1770,14 @@ func stressTests(t *testing.T, rdb *redis.Client, ctx context.Context, encoding
lexSet = slices.Compact(lexSet)

for i := 0; i < 100; i++ {
min, max := util.RandString(0, 30, util.Alpha), util.RandString(0, 30, util.Alpha)
minStr, maxStr := util.RandString(0, 30, util.Alpha), util.RandString(0, 30, util.Alpha)
minInc, maxInc := util.RandomBool(), util.RandomBool()
cMin, cMax := "("+min, "("+max
cMin, cMax := "("+minStr, "("+maxStr
if minInc {
cMin = "[" + min
cMin = "[" + minStr
}
if maxInc {
cMax = "[" + max
cMax = "[" + maxStr
}
rev := util.RandomBool()

Expand All @@ -1797,16 +1797,16 @@ func stressTests(t *testing.T, rdb *redis.Client, ctx context.Context, encoding
// compute the same output by programming
o := make([]string, 0)
c := lexSet
if (!rev && min > max) || (rev && max > min) {
if (!rev && minStr > maxStr) || (rev && maxStr > minStr) {
// empty output when ranges are inverted
} else {
if rev {
c = rdb.ZRevRange(ctx, "zset", 0, -1).Val()
min, max, minInc, maxInc = max, min, maxInc, minInc
minStr, maxStr, minInc, maxInc = maxStr, minStr, maxInc, minInc
}

for _, e := range c {
if (minInc && e >= min || !minInc && e > min) && (maxInc && e <= max || !maxInc && e < max) {
if (minInc && e >= minStr || !minInc && e > minStr) && (maxInc && e <= maxStr || !maxInc && e < maxStr) {
o = append(o, e)
}
}
Expand All @@ -1830,14 +1830,14 @@ func stressTests(t *testing.T, rdb *redis.Client, ctx context.Context, encoding
rdb.ZUnionStore(ctx, "zsetcopy", &redis.ZStore{Keys: []string{"zset"}})
var lexSetCopy []string
lexSetCopy = append(lexSetCopy, lexSet...)
min, max := util.RandString(0, 30, util.Alpha), util.RandString(0, 30, util.Alpha)
minStr, maxStr := util.RandString(0, 30, util.Alpha), util.RandString(0, 30, util.Alpha)
minInc, maxInc := util.RandomBool(), util.RandomBool()
cMin, cMax := "("+min, "("+max
cMin, cMax := "("+minStr, "("+maxStr
if minInc {
cMin = "[" + min
cMin = "[" + minStr
}
if maxInc {
cMax = "[" + max
cMax = "[" + maxStr
}
require.Equal(t, lexSet, rdb.ZRange(ctx, "zset", 0, -1).Val())
toRem := rdb.ZRangeByLex(ctx, "zset", &redis.ZRangeBy{Min: cMin, Max: cMax}).Val()
Expand Down
24 changes: 12 additions & 12 deletions tests/gocase/util/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ func RandPathNoResult(f ...func()) {
f[index]()
}

// RandomSignedInt returns an integer in (-max, max)
func RandomSignedInt(max int32) int64 {
return rand.Int63n(int64(max)*2-1) - int64(max) + 1
// RandomSignedInt returns an integer in (-maxInt, maxInt)
func RandomSignedInt(maxInt int32) int64 {
return rand.Int63n(int64(maxInt)*2-1) - int64(maxInt) + 1
}

// RandomInt return an integer in [0, max)
func RandomInt(max int64) int64 {
return rand.Int63() % max
// RandomInt return an integer in [0, maxInt)
func RandomInt(maxInt int64) int64 {
return rand.Int63() % maxInt
}

func RandomIntWithSeed(max, seed int64) int64 {
func RandomIntWithSeed(maxInt, seed int64) int64 {
r := rand.New(rand.NewSource(seed))
return r.Int63() % max
return r.Int63() % maxInt
}

func RandomBool() bool {
Expand All @@ -61,13 +61,13 @@ const (
Binary
)

func RandString(min, max int, typ RandStringType) string {
return RandStringWithSeed(min, max, typ, rand.Int63())
func RandString(minInt, maxInt int, typ RandStringType) string {
return RandStringWithSeed(minInt, maxInt, typ, rand.Int63())
}

func RandStringWithSeed(min, max int, typ RandStringType, seed int64) string {
func RandStringWithSeed(minInt, maxInt int, typ RandStringType, seed int64) string {
r := rand.New(rand.NewSource(seed))
length := min + r.Intn(max-min+1)
length := minInt + r.Intn(maxInt-minInt+1)

var minVal, maxVal int
switch typ {
Expand Down
2 changes: 1 addition & 1 deletion x.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
CMAKE_REQUIRE_VERSION = (3, 16, 0)
CLANG_FORMAT_REQUIRED_VERSION = (12, 0, 0)
CLANG_TIDY_REQUIRED_VERSION = (12, 0, 0)
GOLANGCI_LINT_REQUIRED_VERSION = (1, 49, 0)
GOLANGCI_LINT_REQUIRED_VERSION = (1, 63, 3)

SEMVER_REGEX = re.compile(
r"""
Expand Down

0 comments on commit a3ae11b

Please sign in to comment.