Примеры ошибок, обнаруженных с помощью диагностики V8014
V8014. Two 'if' statements have identical conditions. The first 'if' statement contains function return, making the second 'if' redundant, or the code contains a logical error.
rancher
V8014 Two 'if' statements have identical conditions. The first 'if' statement contains function return, making the second 'if' redundant, or the code contains a logical error. zz_generated_cluster.x-k8s.io.machine.go 113
func (c *MachineClient) ListAll(opts *types.ListOpts) (....) {
resp := &MachineCollection{}
resp, err := c.List(opts)
if err != nil {
return resp, err
}
data := resp.Data
for next, err := resp.Next();
next != nil && err == nil; next, err = next.Next() {
data = append(data, next.Data...)
resp = next
resp.Data = data
}
if err != nil {
return resp, err
}
return resp, err
}
FerretDB
V8014 Two 'if' statements have identical conditions. The first 'if' statement contains function return, making the second 'if' redundant, or the code contains a logical error. msg_killcursors.go 61
func (h *Handler) msgKillCursors(....) (*middleware.Response, error) {
....
cursorsV, err := getRequiredParamAny(doc, "cursors")
if err != nil {
return nil, err
}
curArr, ok := cursorsV.(wirebson.AnyArray)
if !ok { // <=
msg := fmt.Sprintf(....)
return nil, lazyerrors.Error(....)
}
cursors, err := curArr.Decode()
if !ok { // <=
return nil, lazyerrors.Error(err)
}
....
}
vault
V8014 Two 'if' statements have identical conditions. The first 'if' statement contains function return, making the second 'if' redundant, or the code contains a logical error. login_mfa.go 1099
func (c *Core) PersistTOTPKey(....) error {
ks := &totpKey{
Key: key,
}
val, err := jsonutil.EncodeJSON(ks)
if err != nil {
return err
}
if c.barrier.Put(ctx, &logical.StorageEntry{
Key: fmt.Sprintf(....),
Value: val,
}); err != nil {
return err
}
return nil
}