Skip to content

Commit

Permalink
Fix: Shaowing erros
Browse files Browse the repository at this point in the history
  • Loading branch information
vanshavenger committed Dec 22, 2024
1 parent 8164b4b commit 58556ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion internal/eval/sortedset/sorted_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func DeserializeSortedSet(buf *bytes.Reader) (*Set, error) {
}

// GetRangeByScore returns a slice of members with scores between min and max, inclusive.
func (ss *Set) GetRangeByScore(min, max float64, withScores bool, reverse bool, offset, count int) []string {
func (ss *Set) GetRangeByScore(min, max float64, withScores, reverse bool, offset, count int) []string {

Check failure on line 330 in internal/eval/sortedset/sorted_set.go

View workflow job for this annotation

GitHub Actions / lint

builtinShadow: shadowing of predeclared identifier: min (gocritic)

Check failure on line 330 in internal/eval/sortedset/sorted_set.go

View workflow job for this annotation

GitHub Actions / lint

builtinShadow: shadowing of predeclared identifier: max (gocritic)
var result []string
index := 0
returned := 0
Expand Down
30 changes: 14 additions & 16 deletions internal/eval/store_eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -1137,23 +1137,23 @@ func evalZRANGE(args []string, store *dstore.Store) *EvalResponse {
}
result = sortedSet.GetRangeByScore(start, stop, withScores, reverse, offset, count)
} else {
start, err := strconv.ParseInt(startStr, 10, 64)
start, err := strconv.Atoi(startStr)
if err != nil {
return &EvalResponse{
Result: nil,
Error: diceerrors.ErrIntegerOutOfRange,
}
}

stop, err := strconv.ParseInt(stopStr, 10, 64)
stop, err := strconv.Atoi(stopStr)
if err != nil {
return &EvalResponse{
Result: nil,
Error: diceerrors.ErrIntegerOutOfRange,
}
}

result = sortedSet.GetRange(int(start), int(stop), withScores, reverse)
result = sortedSet.GetRange(start, stop, withScores, reverse)
}

if limit && !byScore && !byLex {
Expand All @@ -1174,36 +1174,34 @@ func evalZRANGE(args []string, store *dstore.Store) *EvalResponse {
}
}

func parseScoreRange(min, max string) (float64, float64, error) {
minScore := math.Inf(-1)
maxScore := math.Inf(1)
func parseScoreRange(minStr, maxStr string) (minScore, maxScore float64, err error) {
minScore = math.Inf(-1)
maxScore = math.Inf(1)

if min != MINUSINF {
var err error
if min[0] == '(' {
minScore, err = strconv.ParseFloat(min[1:], 64)
if minStr != MINUSINF {
if minStr[0] == '(' {
minScore, err = strconv.ParseFloat(minStr[1:], 64)
if err != nil {
return 0, 0, fmt.Errorf("ERR min or max is not a float")
}
minScore = math.Nextafter(minScore, math.Inf(1))
} else {
minScore, err = strconv.ParseFloat(min, 64)
minScore, err = strconv.ParseFloat(minStr, 64)
if err != nil {
return 0, 0, fmt.Errorf("ERR min or max is not a float")
}
}
}

if max != PLUSINF {
var err error
if max[0] == '(' {
maxScore, err = strconv.ParseFloat(max[1:], 64)
if maxStr != PLUSINF {
if maxStr[0] == '(' {
maxScore, err = strconv.ParseFloat(maxStr[1:], 64)
if err != nil {
return 0, 0, fmt.Errorf("ERR min or max is not a float")
}
maxScore = math.Nextafter(maxScore, math.Inf(-1))
} else {
maxScore, err = strconv.ParseFloat(max, 64)
maxScore, err = strconv.ParseFloat(maxStr, 64)
if err != nil {
return 0, 0, fmt.Errorf("ERR min or max is not a float")
}
Expand Down

0 comments on commit 58556ad

Please sign in to comment.