Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ run:
timeout: 3m

linters:
disable:
- errcheck
enable:
- errcheck
- forbidigo
- gocritic
- goimports
Expand Down
12 changes: 6 additions & 6 deletions arrow/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func TestResponseDecode(t *testing.T) {
buf := bytes.NewBuffer([]byte{})
enc := msgpack.NewEncoder(buf)

enc.EncodeMapLen(1)
enc.EncodeUint8(uint8(iproto.IPROTO_DATA))
enc.Encode([]interface{}{'v', '2'})
require.NoError(t, enc.EncodeMapLen(1))
require.NoError(t, enc.EncodeUint8(uint8(iproto.IPROTO_DATA)))
require.NoError(t, enc.Encode([]interface{}{'v', '2'}))

request := arrow.NewInsertRequest(validSpace, arrow.Arrow{})
resp, err := request.Response(header, bytes.NewBuffer(buf.Bytes()))
Expand All @@ -61,9 +61,9 @@ func TestResponseDecodeTyped(t *testing.T) {
buf := bytes.NewBuffer([]byte{})
enc := msgpack.NewEncoder(buf)

enc.EncodeMapLen(1)
enc.EncodeUint8(uint8(iproto.IPROTO_DATA))
enc.EncodeBytes([]byte{'v', '2'})
require.NoError(t, enc.EncodeMapLen(1))
require.NoError(t, enc.EncodeUint8(uint8(iproto.IPROTO_DATA)))
require.NoError(t, enc.EncodeBytes([]byte{'v', '2'}))

request := arrow.NewInsertRequest(validSpace, arrow.Arrow{})
resp, err := request.Response(header, bytes.NewBuffer(buf.Bytes()))
Expand Down
2 changes: 1 addition & 1 deletion box/box_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestMocked_BoxNew(t *testing.T) {
require.NotNil(t, b)

assert.Len(t, mock.Requests, 0)
b.Schema().User().Exists(box.NewInfoRequest().Ctx(), "")
_, _ = b.Schema().User().Exists(box.NewInfoRequest().Ctx(), "")
require.Len(t, mock.Requests, 1)
}

Expand Down
2 changes: 1 addition & 1 deletion boxerror_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestMessagePackDecode(t *testing.T) {
func TestMessagePackUnmarshalToNil(t *testing.T) {
var val *BoxError = nil
require.PanicsWithValue(t, "cannot unmarshal to a nil pointer",
func() { val.UnmarshalMsgpack(mpDecodeSamples["InnerMapExtraKey"].b) })
func() { _ = val.UnmarshalMsgpack(mpDecodeSamples["InnerMapExtraKey"].b) })
}

func TestMessagePackEncodeNil(t *testing.T) {
Expand Down
36 changes: 27 additions & 9 deletions client_tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ type IntKey struct {
}

func (k IntKey) EncodeMsgpack(enc *msgpack.Encoder) error {
enc.EncodeArrayLen(1)
enc.EncodeInt(int64(k.I))
if err := enc.EncodeArrayLen(1); err != nil {
return err
}
if err := enc.EncodeInt(int64(k.I)); err != nil {
return err
}
return nil
}

Expand All @@ -24,8 +28,12 @@ type UintKey struct {
}

func (k UintKey) EncodeMsgpack(enc *msgpack.Encoder) error {
enc.EncodeArrayLen(1)
enc.EncodeUint(uint64(k.I))
if err := enc.EncodeArrayLen(1); err != nil {
return err
}
if err := enc.EncodeUint(uint64(k.I)); err != nil {
return err
}
return nil
}

Expand All @@ -36,8 +44,12 @@ type StringKey struct {
}

func (k StringKey) EncodeMsgpack(enc *msgpack.Encoder) error {
enc.EncodeArrayLen(1)
enc.EncodeString(k.S)
if err := enc.EncodeArrayLen(1); err != nil {
return err
}
if err := enc.EncodeString(k.S); err != nil {
return err
}
return nil
}

Expand All @@ -48,9 +60,15 @@ type IntIntKey struct {
}

func (k IntIntKey) EncodeMsgpack(enc *msgpack.Encoder) error {
enc.EncodeArrayLen(2)
enc.EncodeInt(int64(k.I1))
enc.EncodeInt(int64(k.I2))
if err := enc.EncodeArrayLen(2); err != nil {
return err
}
if err := enc.EncodeInt(int64(k.I1)); err != nil {
return err
}
if err := enc.EncodeInt(int64(k.I2)); err != nil {
return err
}
return nil
}

Expand Down
26 changes: 17 additions & 9 deletions connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func Connect(ctx context.Context, dialer Dialer, opts Opts) (conn *Connection, e
if err != nil {
conn.mutex.Lock()
defer conn.mutex.Unlock()
conn.closeConnection(err, true)
_ = conn.closeConnection(err, true)
return nil, err
}
conn.SetSchema(schema)
Expand Down Expand Up @@ -562,7 +562,9 @@ func pack(h *smallWBuf, enc *msgpack.Encoder, reqid uint32,
byte(reqid >> 8), byte(reqid),
}, streamBytes[:streamBytesLen]...)

h.Write(hBytes)
if _, err = h.Write(hBytes); err != nil {
return
}

if err = req.Body(res, enc); err != nil {
return
Expand Down Expand Up @@ -695,13 +697,13 @@ func (conn *Connection) runReconnects(ctx context.Context) error {
func (conn *Connection) reconnectImpl(neterr error, c Conn) {
if conn.opts.Reconnect > 0 {
if c == conn.c {
conn.closeConnection(neterr, false)
_ = conn.closeConnection(neterr, false)
if err := conn.runReconnects(context.Background()); err != nil {
conn.closeConnection(err, true)
_ = conn.closeConnection(err, true)
}
}
} else {
conn.closeConnection(neterr, true)
_ = conn.closeConnection(neterr, true)
}
}

Expand Down Expand Up @@ -1106,7 +1108,7 @@ func (conn *Connection) putFuture(fut *Future, req Request, streamId uint64) {
RequestId: reqid,
Error: ErrorNo,
}
fut.SetResponse(header, nil)
_ = fut.SetResponse(header, nil)
conn.markDone(fut)
}
}
Expand Down Expand Up @@ -1482,7 +1484,9 @@ func (conn *Connection) newWatcherImpl(key string, callback WatchCallback) (Watc
// request will not be finished by a small per-request
// timeout.
req := newWatchRequest(key).Context(context.Background())
conn.Do(req).Get()
if _, err = conn.Do(req).Get(); err != nil {
return
}
}
}

Expand All @@ -1505,7 +1509,9 @@ func (conn *Connection) newWatcherImpl(key string, callback WatchCallback) (Watc
// not be finished by a small per-request timeout to
// avoid lost of the request.
req := newUnwatchRequest(key).Context(context.Background())
conn.Do(req).Get()
if _, err = conn.Do(req).Get(); err != nil {
return
}
}
conn.watchMap.Delete(key)
close(state.unready)
Expand Down Expand Up @@ -1538,7 +1544,9 @@ func shutdownEventCallback(event WatchEvent) {
// step 2.
val, ok := event.Value.(bool)
if ok && val {
go event.Conn.shutdown(false)
go func() {
_ = event.Conn.shutdown(false)
}()
}
}

Expand Down
2 changes: 1 addition & 1 deletion crud/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ type Objects = interface{}
type MapObject map[string]interface{}

func (o MapObject) EncodeMsgpack(enc *msgpack.Encoder) {
enc.Encode(o)
_ = enc.Encode(o)
}
8 changes: 6 additions & 2 deletions crud/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,12 @@ func encodeOptions(enc *msgpack.Encoder,
if mapLen > 0 {
for i, name := range names {
if exists[i] {
enc.EncodeString(name)
enc.Encode(values[i])
if err := enc.EncodeString(name); err != nil {
return err
}
if err := enc.Encode(values[i]); err != nil {
return err
}
}
}
}
Expand Down
39 changes: 26 additions & 13 deletions crud/tarantool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,8 @@ func TestCrudGenerateData(t *testing.T) {
for i := 1010; i < 1020; i++ {
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
_, err := conn.Do(req).Get()
require.NoError(t, err)
}

data, err := conn.Do(testCase.req).Get()
Expand All @@ -571,7 +572,8 @@ func TestCrudGenerateData(t *testing.T) {
for i := 1010; i < 1020; i++ {
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
_, err := conn.Do(req).Get()
require.NoError(t, err)
}
})
}
Expand All @@ -590,7 +592,8 @@ func TestCrudProcessData(t *testing.T) {
for i := 1010; i < 1020; i++ {
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
_, err := conn.Do(req).Get()
require.NoError(t, err)
}
})
}
Expand Down Expand Up @@ -799,7 +802,8 @@ func TestBoolResult(t *testing.T) {
for i := 1010; i < 1020; i++ {
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
_, err := conn.Do(req).Get()
require.NoError(t, err)
}
}

Expand All @@ -824,7 +828,8 @@ func TestNumberResult(t *testing.T) {
for i := 1010; i < 1020; i++ {
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
_, err = conn.Do(req).Get()
require.NoError(t, err)
}
}

Expand Down Expand Up @@ -869,7 +874,8 @@ func TestBaseResult(t *testing.T) {
for i := 1010; i < 1020; i++ {
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
_, err = conn.Do(req).Get()
require.NoError(t, err)
}
}

Expand Down Expand Up @@ -914,7 +920,8 @@ func TestManyResult(t *testing.T) {
for i := 1010; i < 1020; i++ {
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
_, err := conn.Do(req).Get()
require.NoError(t, err)
}
}

Expand Down Expand Up @@ -1130,7 +1137,8 @@ func TestFetchLatestMetadataOption(t *testing.T) {
for i := 1010; i < 1020; i++ {
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
_, err := conn.Do(req).Get()
require.NoError(t, err)
}

resp := crud.Result{}
Expand All @@ -1147,7 +1155,8 @@ func TestFetchLatestMetadataOption(t *testing.T) {
for i := 1010; i < 1020; i++ {
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
_, err = conn.Do(req).Get()
require.NoError(t, err)
}
})
}
Expand Down Expand Up @@ -1283,7 +1292,8 @@ func TestNoreturnOption(t *testing.T) {
for i := 1010; i < 1020; i++ {
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
_, err := conn.Do(req).Get()
require.NoError(t, err)
}

data, err := conn.Do(testCase.req).Get()
Expand All @@ -1306,7 +1316,8 @@ func TestNoreturnOption(t *testing.T) {
for i := 1010; i < 1020; i++ {
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
_, err = conn.Do(req).Get()
require.NoError(t, err)
}
})
}
Expand All @@ -1321,7 +1332,8 @@ func TestNoreturnOptionTyped(t *testing.T) {
for i := 1010; i < 1020; i++ {
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
_, err := conn.Do(req).Get()
require.NoError(t, err)
}

resp := crud.Result{}
Expand All @@ -1342,7 +1354,8 @@ func TestNoreturnOptionTyped(t *testing.T) {
for i := 1010; i < 1020; i++ {
req := tarantool.NewDeleteRequest(spaceName).
Key([]interface{}{uint(i)})
conn.Do(req).Get()
_, err = conn.Do(req).Get()
require.NoError(t, err)
}
})
}
Expand Down
8 changes: 6 additions & 2 deletions datetime/datetime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,9 @@ func (c *Tuple2) EncodeMsgpack(e *msgpack.Encoder) error {
if err := e.EncodeString(c.Orig); err != nil {
return err
}
e.Encode(c.Events)
if err := e.Encode(c.Events); err != nil {
return err
}
return nil
}

Expand All @@ -879,7 +881,9 @@ func (c *Tuple2) DecodeMsgpack(d *msgpack.Decoder) error {
}
c.Events = make([]Event, l)
for i := 0; i < l; i++ {
d.Decode(&c.Events[i])
if err = d.Decode(&c.Events[i]); err != nil {
return err
}
}
return nil
}
Expand Down
8 changes: 6 additions & 2 deletions deadline_io.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,19 @@ type deadlineIO struct {

func (d *deadlineIO) Write(b []byte) (n int, err error) {
if d.to > 0 {
d.c.SetWriteDeadline(time.Now().Add(d.to))
if err = d.c.SetWriteDeadline(time.Now().Add(d.to)); err != nil {
return
}
}
n, err = d.c.Write(b)
return
}

func (d *deadlineIO) Read(b []byte) (n int, err error) {
if d.to > 0 {
d.c.SetReadDeadline(time.Now().Add(d.to))
if err = d.c.SetReadDeadline(time.Now().Add(d.to)); err != nil {
return
}
}
n, err = d.c.Read(b)
return
Expand Down
Loading
Loading