ronantakizawa/codereview-bench huggingface dataset:
Repository: DiceDB/dice
File: internal/observability/ping.go (Go)

Code before:
	hwConfig, err := GetHardwareMeta()
	if err != nil {
		return
	}

	payload := &PingPayload{
		HardwareConfig: hwConfig,
		InstanceID:     config.DiceConfig.InstanceID,
		Version:        config.DiceConfig.Server.Version,
		Err:            err,
		Date:           time.Now().UTC().Format("2006-01-02 15:04:05"),
		DBConfig:       DBConfig{},
	}

	b, _ := json.Marshal(payload)
	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()

	req, _ := http.NewRequestWithContext(ctx, "POST", url, bytes.NewBuffer(b))
	req.Header.Set("Authorization", "Bearer "+token)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: time.Second * 5}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	_ = resp.Body.Close()
}


Review comment (bug):
@JyotinderSingh please add your thoughts around the `panic` here? Was thinking should we panic if the `PING` fails or we can log error?
We can add integration test around it so that we get to know if token expires or something.

Code after:
func Ping(logger *slog.Logger) {
	hwConfig, err := GetHardwareMeta()
	if err != nil {
		return
	}

	payload := &PingPayload{
		HardwareConfig: hwConfig,
		InstanceID:     config.DiceConfig.InstanceID,
		Version:        config.DiceConfig.Server.Version,
		Err:            err,
		Date:           time.Now().UTC().Format("2006-01-02 15:04:05"),
		DBConfig:       DBConfig{},
	}

	b, _ := json.Marshal(payload)
	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()

	req, _ := http.NewRequestWithContext(ctx, "POST", url, bytes.NewBuffer(b))
	req.Header.Set("Authorization", "Bearer "+token)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: time.Second * 5}
	resp, err := client.Do(req)
	if err != nil {
		logger.Error("Error reporting observability metrics.", slog.Any("error", err))
		return
	}

	_ = resp.Body.Close()
}
Repository: DiceDB/dice
File: internal/eval/store_eval.go (Go)

Code before:
	return &EvalResponse{
		Result: added,
		Error:  nil,
	}
}

// The ZCOUNT command in DiceDB counts the number of members in a sorted set at the specified key
// whose scores fall within a given range. The command takes three arguments: the key of the sorted set
// the minimum score, and the maximum score.
func evalZCOUNT(args []string, store *dstore.Store) *EvalResponse {
	if len(args) != 3 {
		return &EvalResponse{
			Result: nil,
			Error:  diceerrors.ErrWrongArgumentCount("ZCOUNT"),
		}
	}

	key := args[0]
	obj := store.Get(key)

	if obj == nil {
		return &EvalResponse{
			Result: 0,
			Error:  nil,
		}
	}

	var sortedSet *sortedset.Set
	var err []byte
	sortedSet, err = sortedset.FromObject(obj)
	if err != nil {
		return &EvalResponse{
			Result: nil,
			Error:  diceerrors.ErrWrongTypeOperation,
		}
	}
	minValue, errMin := utils.ParseScore(args[1])
	maxValue, errMax := utils.ParseScore(args[2])

	if errMin != nil || errMax != nil {
		return &EvalResponse{
			Result: nil,
			Error:  diceerrors.ErrInvalidNumberFormat,
		}
	}

	count := sortedSet.CountInRange(minValue, maxValue)

	return &EvalResponse{
		Result: count,
		Error:  nil,

Review comment (suggestion):
Please verify the order in which ZCOUNT validates the arguments. Here we are returning 0 even for below command:
```bash
zcount key a b
```

Code after:
	return &EvalResponse{
		Result: added,
		Error:  nil,
	}
}

// The ZCOUNT command in DiceDB counts the number of members in a sorted set at the specified key
// whose scores fall within a given range. The command takes three arguments: the key of the sorted set
// the minimum score, and the maximum score.
func evalZCOUNT(args []string, store *dstore.Store) *EvalResponse {
	if len(args) != 3 {
		// 1. Check no of arguments
		return &EvalResponse{
			Result: nil,
			Error:  diceerrors.ErrWrongArgumentCount("ZCOUNT"),
		}
	}

	key := args[0]
	minArg := args[1]
	maxArg := args[2]

	// 2. Parse the min and max score arguments
	minValue, errMin := strconv.ParseFloat(minArg, 64)
	maxValue, errMax := strconv.ParseFloat(maxArg, 64)
	if errMin != nil || errMax != nil {
		return &EvalResponse{
			Result: nil,
			Error:  diceerrors.ErrInvalidNumberFormat,
		}
	}

	// 3. Retrieve the object from the store
	obj := store.Get(key)
	if obj == nil {
		// If the key does not exist, return 0 (no error)
		return &EvalResponse{
			Result: 0,
			Error:  nil,
		}
	}

	// 4. Ensure the object is a valid sorted set
	var sortedSet *sortedset.Set
	var err []byte
	sortedSet, err = sortedset.FromObject(obj)
	if err != nil {
		return &EvalResponse{
			Result: nil,
			Error:  diceerrors.ErrWrongTypeOperation,
		}
Repository: DiceDB/dice
File: internal/eval/store_eval.go (Go)

Code before:
			if exDurationMs < 0 {
				exDurationMs = 0
			}
			state = Initialized

		case XX:
			// Get the key from the hash table
			obj := store.Get(key)

			// if key does not exist, return RESP encoded nil
			if obj == nil {
				return makeEvalResult(clientio.NIL)
			}
		case NX:
			obj := store.Get(key)
			if obj != nil {
				return makeEvalResult(clientio.NIL)
			}
		case KeepTTL:
			if state != Uninitialized {
				return makeEvalError(diceerrors.ErrSyntax)
			}
			keepttl = true
		case GET:
			getVal = true
			oldVal := evalGET([]string{key}, store)
			if oldVal.Error != nil {
				return makeEvalError(diceerrors.ErrWrongTypeOperation)
			}
			getOldVal = oldVal.Result
		default:
			return makeEvalError(diceerrors.ErrSyntax)
		}
	}

	// Cast the value properly based on the encoding type
	var storedValue interface{}
	switch oEnc {
	case object.ObjEncodingInt:
		storedValue, _ = strconv.ParseInt(value, 10, 64)
	case object.ObjEncodingEmbStr, object.ObjEncodingRaw:
		storedValue = value
	default:
		return makeEvalError(diceerrors.ErrUnsupportedEncoding(int(oEnc)))
	}

	// putting the k and value in a Hash Table
	store.Put(key, store.NewObj(storedValue, exDurationMs, oType, oEnc), dstore.WithKeepTTL(keepttl))
	if getVal {
		return makeEvalResult(getOldVal)
	}

Review comment (bug):
```suggestion
			evalGet := evalGET([]string{key}, store)
			if evalGet.Error != nil {
				return makeEvalError(diceerrors.ErrWrongTypeOperation)
			}
			oldVal = &evalGet.Result
```

Code after:
				exDurationMs = 0
			}
			state = Initialized

		case XX:
			// Get the key from the hash table
			obj := store.Get(key)

			// if key does not exist, return RESP encoded nil
			if obj == nil {
				return makeEvalResult(clientio.NIL)
			}
		case NX:
			obj := store.Get(key)
			if obj != nil {
				return makeEvalResult(clientio.NIL)
			}
		case KeepTTL:
			if state != Uninitialized {
				return makeEvalError(diceerrors.ErrSyntax)
			}
			keepttl = true
		case GET:
			getResult := evalGET([]string{key}, store)
			if getResult.Error != nil {
				return makeEvalError(diceerrors.ErrWrongTypeOperation)
			}
			oldVal = &getResult.Result
		default:
			return makeEvalError(diceerrors.ErrSyntax)
		}
	}

	// Cast the value properly based on the encoding type
	var storedValue interface{}
	switch oEnc {
	case object.ObjEncodingInt:
		storedValue, _ = strconv.ParseInt(value, 10, 64)
	case object.ObjEncodingEmbStr, object.ObjEncodingRaw:
		storedValue = value
	default:
		return makeEvalError(diceerrors.ErrUnsupportedEncoding(int(oEnc)))
	}

	// putting the k and value in a Hash Table
	store.Put(key, store.NewObj(storedValue, exDurationMs, oType, oEnc), dstore.WithKeepTTL(keepttl))
	if oldVal != nil {
		return makeEvalResult(*oldVal)
	}
	return makeEvalResult(clientio.OK)
}
Repository: DiceDB/dice
File: internal/eval/store_eval.go (Go)

Code before:
		case GET:
			getVal = true
			oldVal := evalGET([]string{key}, store)
			if oldVal.Error != nil {
				return makeEvalError(diceerrors.ErrWrongTypeOperation)
			}
			getOldVal = oldVal.Result
		default:
			return makeEvalError(diceerrors.ErrSyntax)
		}
	}

	// Cast the value properly based on the encoding type
	var storedValue interface{}
	switch oEnc {
	case object.ObjEncodingInt:
		storedValue, _ = strconv.ParseInt(value, 10, 64)
	case object.ObjEncodingEmbStr, object.ObjEncodingRaw:
		storedValue = value
	default:
		return makeEvalError(diceerrors.ErrUnsupportedEncoding(int(oEnc)))
	}

	// putting the k and value in a Hash Table
	store.Put(key, store.NewObj(storedValue, exDurationMs, oType, oEnc), dstore.WithKeepTTL(keepttl))
	if getVal {
		return makeEvalResult(getOldVal)
	}
	return makeEvalResult(clientio.OK)
}

// evalGET returns the value for the queried key in args
// The key should be the only param in args
// The RESP value of the key is encoded and then returned
// evalGET returns response.clientio.NIL if key is expired or it does not exist
func evalGET(args []string, store *dstore.Store) *EvalResponse {
	if len(args) != 1 {
		return &EvalResponse{
			Result: nil,
			Error:  diceerrors.ErrWrongArgumentCount("GET"),
		}
	}

	key := args[0]

	obj := store.Get(key)

	// if key does not exist, return RESP encoded nil
	if obj == nil {
		return &EvalResponse{
			Result: clientio.NIL,

Review comment (suggestion):
```suggestion
	if oldVal != nil {
		return makeEvalResult(*oldVal)
	}
```

Code after:
			getResult := evalGET([]string{key}, store)
			if getResult.Error != nil {
				return makeEvalError(diceerrors.ErrWrongTypeOperation)
			}
			oldVal = &getResult.Result
		default:
			return makeEvalError(diceerrors.ErrSyntax)
		}
	}

	// Cast the value properly based on the encoding type
	var storedValue interface{}
	switch oEnc {
	case object.ObjEncodingInt:
		storedValue, _ = strconv.ParseInt(value, 10, 64)
	case object.ObjEncodingEmbStr, object.ObjEncodingRaw:
		storedValue = value
	default:
		return makeEvalError(diceerrors.ErrUnsupportedEncoding(int(oEnc)))
	}

	// putting the k and value in a Hash Table
	store.Put(key, store.NewObj(storedValue, exDurationMs, oType, oEnc), dstore.WithKeepTTL(keepttl))
	if oldVal != nil {
		return makeEvalResult(*oldVal)
	}
	return makeEvalResult(clientio.OK)
}

// evalGET returns the value for the queried key in args
// The key should be the only param in args
// The RESP value of the key is encoded and then returned
// evalGET returns response.clientio.NIL if key is expired or it does not exist
func evalGET(args []string, store *dstore.Store) *EvalResponse {
	if len(args) != 1 {
		return &EvalResponse{
			Result: nil,
			Error:  diceerrors.ErrWrongArgumentCount("GET"),
		}
	}

	key := args[0]

	obj := store.Get(key)

	// if key does not exist, return RESP encoded nil
	if obj == nil {
		return &EvalResponse{
			Result: clientio.NIL,
			Error:  nil,
		}
Repository: DiceDB/dice
File: config/config.go (Go)

Code before:
	if err != nil {
		slog.Warn("Failed to create default preferences directory", slog.String("error", err.Error()))
	}
}

func createDefaultParentDir() (string, error) {
	// Get the default directory path for the OS
	prefDir := GetDefaultParentDirPath()
	if err := os.MkdirAll(prefDir, os.ModePerm); err != nil {
		return "", fmt.Errorf("failed to create preferences directory: %w", err)
	}

	return prefDir, nil
}

func GetDefaultParentDirPath() string {
	switch runtime.GOOS {
	case "linux":
		return linuxPath
	case "darwin":
		return expandHomeDirDarwin(darwinPath)
	case "windows":
		return windowsPath
	default:
		slog.Warn("unsupported OS, defaulting to current directory")
		return DefaultParentDir
	}
}

func expandHomeDirDarwin(path string) string {
	if path != "" && path[0] == '~' {
		home, err := os.UserHomeDir()
		if err != nil {
			return path // Fallback if home directory can't be resolved
		}
		return filepath.Join(home, path[1:])
	}
	return path
}


Review comment (suggestion):
There should not be any default. The same variable is defined across three files and that same var is ref in constants and then used here. I do not see we need this function at all after the above changes.

Code after:

	for i := 0; i < configType.NumField(); i++ {
		field := configType.Field(i)
		value := configValue.Field(i)

		tag := field.Tag.Get("default")
		if tag != "" {
			switch value.Kind() {
			case reflect.String:
				value.SetString(tag)
			case reflect.Int:
				intVal := 0
				_, err := fmt.Sscanf(tag, "%d", &intVal)
				if err == nil {
					value.SetInt(int64(intVal))
				}
			case reflect.Bool:
				boolVal := false
				_, err := fmt.Sscanf(tag, "%t", &boolVal)
				if err == nil {
					value.SetBool(boolVal)
				}
			}
		}
	}

	return defaultConfig
}

func ForceInit(config *DiceDBConfig) {
	defaultConfig := initDefaultConfig()

	configType := reflect.TypeOf(*config)
	configValue := reflect.ValueOf(config).Elem()

	defaultConfigValue := reflect.ValueOf(defaultConfig).Elem()

	for i := 0; i < configType.NumField(); i++ {
		value := configValue.Field(i)
		defaultValue := defaultConfigValue.Field(i)
		if value.Interface() == reflect.Zero(value.Type()).Interface() {
			value.Set(defaultValue)
		}
	}

	Config = config
}
Repository: DiceDB/dice
File: config/config.go (Go)

Code before:
}

func GetDefaultParentDirPath() string {
	switch runtime.GOOS {
	case "linux":
		return linuxPath
	case "darwin":
		return expandHomeDirDarwin(darwinPath)
	case "windows":
		return windowsPath
	default:
		slog.Warn("unsupported OS, defaulting to current directory")
		return DefaultParentDir
	}
}

func expandHomeDirDarwin(path string) string {
	if path != "" && path[0] == '~' {
		home, err := os.UserHomeDir()
		if err != nil {
			return path // Fallback if home directory can't be resolved
		}
		return filepath.Join(home, path[1:])
	}
	return path
}


Review comment (bug):
Again, this might not be required. Let's have absolute paths only, the more we support this, the more are the edge cases that we will need tp handle.

Code after:
				if err == nil {
					value.SetInt(int64(intVal))
				}
			case reflect.Bool:
				boolVal := false
				_, err := fmt.Sscanf(tag, "%t", &boolVal)
				if err == nil {
					value.SetBool(boolVal)
				}
			}
		}
	}

	return defaultConfig
}

func ForceInit(config *DiceDBConfig) {
	defaultConfig := initDefaultConfig()

	configType := reflect.TypeOf(*config)
	configValue := reflect.ValueOf(config).Elem()

	defaultConfigValue := reflect.ValueOf(defaultConfig).Elem()

	for i := 0; i < configType.NumField(); i++ {
		value := configValue.Field(i)
		defaultValue := defaultConfigValue.Field(i)
		if value.Interface() == reflect.Zero(value.Type()).Interface() {
			value.Set(defaultValue)
		}
	}

	Config = config
}
Repository: DiceDB/dice
File: internal/cmd/cmd_decr.go (Go)

Code before:
	"github.com/dicedb/dice/internal/object"
	dstore "github.com/dicedb/dice/internal/store"
	"github.com/dicedb/dice/wire"
)

var cDECR = &DiceDBCommand{
	Name:      "DECR",
	HelpShort: "DECR decrements the value of the specified key in args by 1",
	Eval:      evalDECR,
}

func init() {
	commandRegistry.AddCommand(cDECR)
}

//nolint:gocyclo
func evalDECR(c *Cmd, s *dstore.Store) (*CmdRes, error) {
	if len(c.C.Args) <= 1 {
		return cmdResNil, errWrongArgumentCount("DECR")
	}
	incr := int64(-1)

	key := c.C.Args[0]
	obj := s.Get(key)
	if obj == nil {
		obj = s.NewObj(incr, -1, object.ObjTypeInt)
		s.Put(key, obj)
		return &CmdRes{R: &wire.Response{
			Value: &wire.Response_VInt{VInt: incr},
		}}, nil
	}

	// if the type is not KV : return wrong type error
	// if the encoding or type is not int : return value is not an int error
	if err := object.AssertTypeWithError(obj.Type, object.ObjTypeString); err == nil {
		return cmdResNil, errIntegerOutOfRange("DECR")
	}

	if errTypeInt := object.AssertType(obj.Type, object.ObjTypeInt); errTypeInt != nil {
		return cmdResNil, errWrongTypeOperation("DECR")
	}

	i, _ := obj.Value.(int64)
	if (incr < 0 && i < 0 && incr < (math.MinInt64-i)) ||
		(incr > 0 && i > 0 && incr > (math.MaxInt64-i)) {
		return cmdResNil, errOverflow("DECR")
	}

	i += incr
	obj.Value = i
	return &CmdRes{R: &wire.Response{

Review comment (suggestion):
Create a contant in the `cmd` module called `INFINITE_EXPIRATION` and set the value to be `-1`. Use it here. This way, we will be able to reuse the same variable throughout the codebase.

Code after:
	"github.com/dicedb/dice/internal/object"
	dstore "github.com/dicedb/dice/internal/store"
	"github.com/dicedb/dice/wire"
)

var cDECR = &DiceDBCommand{
	Name:      "DECR",
	HelpShort: "DECR decrements the value of the specified key in args by 1",
	Eval:      evalDECR,
}

func init() {
	commandRegistry.AddCommand(cDECR)
}

func evalDECR(c *Cmd, s *dstore.Store) (*CmdRes, error) {
	if len(c.C.Args) <= 1 {
		return cmdResNil, errWrongArgumentCount("DECR")
	}

	incr := int64(-1)

	key := c.C.Args[0]
	obj := s.Get(key)
	if obj == nil {
		obj = s.NewObj(incr, INFINITE_EXPIRATION, object.ObjTypeInt)
		s.Put(key, obj)
		return &CmdRes{R: &wire.Response{
			Value: &wire.Response_VInt{VInt: incr},
		}}, nil
	}

	switch obj.Type {
	case object.ObjTypeString:
		return cmdResNil, errIntegerOutOfRange
	case object.ObjTypeInt:
		return cmdResNil, errWrongTypeOperation("DECR")
	}

	i, _ := obj.Value.(int64)
	if (incr < 0 && i < 0 && incr < (math.MinInt64-i)) ||
		(incr > 0 && i > 0 && incr > (math.MaxInt64-i)) {
		return cmdResNil, errIntegerOutOfRange
	}

	i += incr
	obj.Value = i
	return &CmdRes{R: &wire.Response{
		Value: &wire.Response_VInt{VInt: i},
	}}, nil
}
Repository: DiceDB/dice
File: internal/cmd/cmd_decr.go (Go)

Code before:
//nolint:gocyclo
func evalDECR(c *Cmd, s *dstore.Store) (*CmdRes, error) {
	if len(c.C.Args) <= 1 {
		return cmdResNil, errWrongArgumentCount("DECR")
	}
	incr := int64(-1)

	key := c.C.Args[0]
	obj := s.Get(key)
	if obj == nil {
		obj = s.NewObj(incr, -1, object.ObjTypeInt)
		s.Put(key, obj)
		return &CmdRes{R: &wire.Response{
			Value: &wire.Response_VInt{VInt: incr},
		}}, nil
	}

	// if the type is not KV : return wrong type error
	// if the encoding or type is not int : return value is not an int error
	if err := object.AssertTypeWithError(obj.Type, object.ObjTypeString); err == nil {
		return cmdResNil, errIntegerOutOfRange("DECR")
	}

	if errTypeInt := object.AssertType(obj.Type, object.ObjTypeInt); errTypeInt != nil {
		return cmdResNil, errWrongTypeOperation("DECR")
	}

	i, _ := obj.Value.(int64)
	if (incr < 0 && i < 0 && incr < (math.MinInt64-i)) ||
		(incr > 0 && i > 0 && incr > (math.MaxInt64-i)) {
		return cmdResNil, errOverflow("DECR")
	}

	i += incr
	obj.Value = i
	return &CmdRes{R: &wire.Response{
		Value: &wire.Response_VInt{VInt: i},
	}}, nil
}


Review comment (suggestion):
Club both of these in one. Also, we need not use this `AssertTypeWithError` or `AssertType` function, given now it is super easy to check for type of the object. You can directly compare the type using `struct ObjectType`.

Code after:
func evalDECR(c *Cmd, s *dstore.Store) (*CmdRes, error) {
	if len(c.C.Args) <= 1 {
		return cmdResNil, errWrongArgumentCount("DECR")
	}

	incr := int64(-1)

	key := c.C.Args[0]
	obj := s.Get(key)
	if obj == nil {
		obj = s.NewObj(incr, INFINITE_EXPIRATION, object.ObjTypeInt)
		s.Put(key, obj)
		return &CmdRes{R: &wire.Response{
			Value: &wire.Response_VInt{VInt: incr},
		}}, nil
	}

	switch obj.Type {
	case object.ObjTypeString:
		return cmdResNil, errIntegerOutOfRange
	case object.ObjTypeInt:
		return cmdResNil, errWrongTypeOperation("DECR")
	}

	i, _ := obj.Value.(int64)
	if (incr < 0 && i < 0 && incr < (math.MinInt64-i)) ||
		(incr > 0 && i > 0 && incr > (math.MaxInt64-i)) {
		return cmdResNil, errIntegerOutOfRange
	}

	i += incr
	obj.Value = i
	return &CmdRes{R: &wire.Response{
		Value: &wire.Response_VInt{VInt: i},
	}}, nil
}
Repository: DiceDB/dice
File: internal/cmd/cmds.go (Go)

Code before:
func (cmd *DiceDBCmd) Key() string {
	var c string
	if len(cmd.Args) > 0 {
		c = cmd.Args[0]
	}
	return c
}

func errWrongArgumentCount(command string) error {
	return fmt.Errorf("wrong number of arguments for '%s' command", strings.ToUpper(command))
}

var errUnknownObjectType = errors.New("unknown object type")

//nolint:unparam
func errInvalidSyntax(command string) error {
	return fmt.Errorf("invalid syntax for '%s' command", strings.ToUpper(command))
}

//nolint:unparam
func errInvalidValue(command, param string) error {
	return fmt.Errorf("invalid value for a parameter in '%s' command for %s parameter", strings.ToUpper(command), strings.ToUpper(param))
}

//nolint:unparam
func errIntegerOutOfRange(command string) error {
	return fmt.Errorf("integer out of range for '%s' command", strings.ToUpper(command))
}

//nolint:unparam
func errWrongTypeOperation(command string) error {
	return fmt.Errorf("wrong type operation for '%s' command", strings.ToUpper(command))
}

//nolint:unparam
func errOverflow(command string) error {
	return fmt.Errorf("overflow for '%s' command", strings.ToUpper(command))
}

var cmdResNil = &CmdRes{R: &wire.Response{
	Value: &wire.Response_VNil{VNil: true},
}}

var cmdResOK = &CmdRes{R: &wire.Response{
	Value: &wire.Response_VStr{VStr: "OK"},
}}


Review comment (bug):
given the error, we need not pass `command` to this. this should be a genetic `overflow` error.

Code after:
// This is not true for all commands, however, for now this is only used by the watch manager,
// which as of now only supports a small subset of commands (all of which fit this implementation).
func (cmd *DiceDBCmd) Key() string {
	var c string
	if len(cmd.Args) > 0 {
		c = cmd.Args[0]
	}
	return c
}

func errWrongArgumentCount(command string) error {
	return fmt.Errorf("wrong number of arguments for '%s' command", strings.ToUpper(command))
}

var errUnknownObjectType = errors.New("unknown object type")
var errIntegerOutOfRange = errors.New("integer out of range")

//nolint:unparam
func errInvalidSyntax(command string) error {
	return fmt.Errorf("invalid syntax for '%s' command", strings.ToUpper(command))
}

//nolint:unparam
func errInvalidValue(command, param string) error {
	return fmt.Errorf("invalid value for a parameter in '%s' command for %s parameter", strings.ToUpper(command), strings.ToUpper(param))
}

//nolint:unparam
func errWrongTypeOperation(command string) error {
	return fmt.Errorf("wrong type operation for '%s' command", strings.ToUpper(command))
}

var cmdResNil = &CmdRes{R: &wire.Response{
	Value: &wire.Response_VNil{VNil: true},
}}

var cmdResOK = &CmdRes{R: &wire.Response{
	Value: &wire.Response_VStr{VStr: "OK"},
}}