Skip to content

Commit e83e35f

Browse files
committed
lint: enabled errcheck
Tests and methods are updated with enabling `errcheck` for `golangci-lint` check.
1 parent aff7842 commit e83e35f

33 files changed

+135
-119
lines changed

.golangci.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ run:
22
timeout: 3m
33

44
linters:
5-
disable:
6-
- errcheck
75
enable:
6+
- errcheck
87
- forbidigo
98
- gocritic
109
- goimports

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
1212

1313
* New types for MessagePack extensions compatible with go-option (#459).
1414
* Added `box.MustNew` wrapper for `box.New` without an error (#448).
15+
* Enabled `errcheck` in linter.
1516

1617
### Changed
1718

arrow/request_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ func TestResponseDecode(t *testing.T) {
4242
buf := bytes.NewBuffer([]byte{})
4343
enc := msgpack.NewEncoder(buf)
4444

45-
enc.EncodeMapLen(1)
46-
enc.EncodeUint8(uint8(iproto.IPROTO_DATA))
47-
enc.Encode([]interface{}{'v', '2'})
45+
_ = enc.EncodeMapLen(1)
46+
_ = enc.EncodeUint8(uint8(iproto.IPROTO_DATA))
47+
_ = enc.Encode([]interface{}{'v', '2'})
4848

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

64-
enc.EncodeMapLen(1)
65-
enc.EncodeUint8(uint8(iproto.IPROTO_DATA))
66-
enc.EncodeBytes([]byte{'v', '2'})
64+
_ = enc.EncodeMapLen(1)
65+
_ = enc.EncodeUint8(uint8(iproto.IPROTO_DATA))
66+
_ = enc.EncodeBytes([]byte{'v', '2'})
6767

6868
request := arrow.NewInsertRequest(validSpace, arrow.Arrow{})
6969
resp, err := request.Response(header, bytes.NewBuffer(buf.Bytes()))

box/box_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestMocked_BoxNew(t *testing.T) {
3838
require.NotNil(t, b)
3939

4040
assert.Len(t, mock.Requests, 0)
41-
b.Schema().User().Exists(box.NewInfoRequest().Ctx(), "")
41+
_, _ = b.Schema().User().Exists(box.NewInfoRequest().Ctx(), "")
4242
require.Len(t, mock.Requests, 1)
4343
}
4444

boxerror_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func TestMessagePackDecode(t *testing.T) {
204204
func TestMessagePackUnmarshalToNil(t *testing.T) {
205205
var val *BoxError = nil
206206
require.PanicsWithValue(t, "cannot unmarshal to a nil pointer",
207-
func() { val.UnmarshalMsgpack(mpDecodeSamples["InnerMapExtraKey"].b) })
207+
func() { _ = val.UnmarshalMsgpack(mpDecodeSamples["InnerMapExtraKey"].b) })
208208
}
209209

210210
func TestMessagePackEncodeNil(t *testing.T) {

client_tools.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ type IntKey struct {
1111
}
1212

1313
func (k IntKey) EncodeMsgpack(enc *msgpack.Encoder) error {
14-
enc.EncodeArrayLen(1)
15-
enc.EncodeInt(int64(k.I))
14+
_ = enc.EncodeArrayLen(1)
15+
_ = enc.EncodeInt(int64(k.I))
1616
return nil
1717
}
1818

@@ -24,8 +24,8 @@ type UintKey struct {
2424
}
2525

2626
func (k UintKey) EncodeMsgpack(enc *msgpack.Encoder) error {
27-
enc.EncodeArrayLen(1)
28-
enc.EncodeUint(uint64(k.I))
27+
_ = enc.EncodeArrayLen(1)
28+
_ = enc.EncodeUint(uint64(k.I))
2929
return nil
3030
}
3131

@@ -36,8 +36,8 @@ type StringKey struct {
3636
}
3737

3838
func (k StringKey) EncodeMsgpack(enc *msgpack.Encoder) error {
39-
enc.EncodeArrayLen(1)
40-
enc.EncodeString(k.S)
39+
_ = enc.EncodeArrayLen(1)
40+
_ = enc.EncodeString(k.S)
4141
return nil
4242
}
4343

@@ -48,9 +48,9 @@ type IntIntKey struct {
4848
}
4949

5050
func (k IntIntKey) EncodeMsgpack(enc *msgpack.Encoder) error {
51-
enc.EncodeArrayLen(2)
52-
enc.EncodeInt(int64(k.I1))
53-
enc.EncodeInt(int64(k.I2))
51+
_ = enc.EncodeArrayLen(2)
52+
_ = enc.EncodeInt(int64(k.I1))
53+
_ = enc.EncodeInt(int64(k.I2))
5454
return nil
5555
}
5656

connection.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func Connect(ctx context.Context, dialer Dialer, opts Opts) (conn *Connection, e
401401
if err != nil {
402402
conn.mutex.Lock()
403403
defer conn.mutex.Unlock()
404-
conn.closeConnection(err, true)
404+
_ = conn.closeConnection(err, true)
405405
return nil, err
406406
}
407407
conn.SetSchema(schema)
@@ -562,7 +562,7 @@ func pack(h *smallWBuf, enc *msgpack.Encoder, reqid uint32,
562562
byte(reqid >> 8), byte(reqid),
563563
}, streamBytes[:streamBytesLen]...)
564564

565-
h.Write(hBytes)
565+
_, _ = h.Write(hBytes)
566566

567567
if err = req.Body(res, enc); err != nil {
568568
return
@@ -695,13 +695,13 @@ func (conn *Connection) runReconnects(ctx context.Context) error {
695695
func (conn *Connection) reconnectImpl(neterr error, c Conn) {
696696
if conn.opts.Reconnect > 0 {
697697
if c == conn.c {
698-
conn.closeConnection(neterr, false)
698+
_ = conn.closeConnection(neterr, false)
699699
if err := conn.runReconnects(context.Background()); err != nil {
700-
conn.closeConnection(err, true)
700+
_ = conn.closeConnection(err, true)
701701
}
702702
}
703703
} else {
704-
conn.closeConnection(neterr, true)
704+
_ = conn.closeConnection(neterr, true)
705705
}
706706
}
707707

@@ -1106,7 +1106,7 @@ func (conn *Connection) putFuture(fut *Future, req Request, streamId uint64) {
11061106
RequestId: reqid,
11071107
Error: ErrorNo,
11081108
}
1109-
fut.SetResponse(header, nil)
1109+
_ = fut.SetResponse(header, nil)
11101110
conn.markDone(fut)
11111111
}
11121112
}
@@ -1482,7 +1482,7 @@ func (conn *Connection) newWatcherImpl(key string, callback WatchCallback) (Watc
14821482
// request will not be finished by a small per-request
14831483
// timeout.
14841484
req := newWatchRequest(key).Context(context.Background())
1485-
conn.Do(req).Get()
1485+
_, _ = conn.Do(req).Get()
14861486
}
14871487
}
14881488

@@ -1505,7 +1505,7 @@ func (conn *Connection) newWatcherImpl(key string, callback WatchCallback) (Watc
15051505
// not be finished by a small per-request timeout to
15061506
// avoid lost of the request.
15071507
req := newUnwatchRequest(key).Context(context.Background())
1508-
conn.Do(req).Get()
1508+
_, _ = conn.Do(req).Get()
15091509
}
15101510
conn.watchMap.Delete(key)
15111511
close(state.unready)
@@ -1538,7 +1538,9 @@ func shutdownEventCallback(event WatchEvent) {
15381538
// step 2.
15391539
val, ok := event.Value.(bool)
15401540
if ok && val {
1541-
go event.Conn.shutdown(false)
1541+
go func() {
1542+
_ = event.Conn.shutdown(false)
1543+
}()
15421544
}
15431545
}
15441546

crud/object.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ type Objects = interface{}
2020
type MapObject map[string]interface{}
2121

2222
func (o MapObject) EncodeMsgpack(enc *msgpack.Encoder) {
23-
enc.Encode(o)
23+
_ = enc.Encode(o)
2424
}

crud/options.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,8 @@ func encodeOptions(enc *msgpack.Encoder,
398398
if mapLen > 0 {
399399
for i, name := range names {
400400
if exists[i] {
401-
enc.EncodeString(name)
402-
enc.Encode(values[i])
401+
_ = enc.EncodeString(name)
402+
_ = enc.Encode(values[i])
403403
}
404404
}
405405
}

crud/tarantool_test.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ func TestCrudGenerateData(t *testing.T) {
559559
for i := 1010; i < 1020; i++ {
560560
req := tarantool.NewDeleteRequest(spaceName).
561561
Key([]interface{}{uint(i)})
562-
conn.Do(req).Get()
562+
_, _ = conn.Do(req).Get()
563563
}
564564

565565
data, err := conn.Do(testCase.req).Get()
@@ -571,7 +571,7 @@ func TestCrudGenerateData(t *testing.T) {
571571
for i := 1010; i < 1020; i++ {
572572
req := tarantool.NewDeleteRequest(spaceName).
573573
Key([]interface{}{uint(i)})
574-
conn.Do(req).Get()
574+
_, _ = conn.Do(req).Get()
575575
}
576576
})
577577
}
@@ -590,7 +590,7 @@ func TestCrudProcessData(t *testing.T) {
590590
for i := 1010; i < 1020; i++ {
591591
req := tarantool.NewDeleteRequest(spaceName).
592592
Key([]interface{}{uint(i)})
593-
conn.Do(req).Get()
593+
_, _ = conn.Do(req).Get()
594594
}
595595
})
596596
}
@@ -799,7 +799,7 @@ func TestBoolResult(t *testing.T) {
799799
for i := 1010; i < 1020; i++ {
800800
req := tarantool.NewDeleteRequest(spaceName).
801801
Key([]interface{}{uint(i)})
802-
conn.Do(req).Get()
802+
_, _ = conn.Do(req).Get()
803803
}
804804
}
805805

@@ -824,7 +824,7 @@ func TestNumberResult(t *testing.T) {
824824
for i := 1010; i < 1020; i++ {
825825
req := tarantool.NewDeleteRequest(spaceName).
826826
Key([]interface{}{uint(i)})
827-
conn.Do(req).Get()
827+
_, _ = conn.Do(req).Get()
828828
}
829829
}
830830

@@ -869,7 +869,7 @@ func TestBaseResult(t *testing.T) {
869869
for i := 1010; i < 1020; i++ {
870870
req := tarantool.NewDeleteRequest(spaceName).
871871
Key([]interface{}{uint(i)})
872-
conn.Do(req).Get()
872+
_, _ = conn.Do(req).Get()
873873
}
874874
}
875875

@@ -914,7 +914,7 @@ func TestManyResult(t *testing.T) {
914914
for i := 1010; i < 1020; i++ {
915915
req := tarantool.NewDeleteRequest(spaceName).
916916
Key([]interface{}{uint(i)})
917-
conn.Do(req).Get()
917+
_, _ = conn.Do(req).Get()
918918
}
919919
}
920920

@@ -1130,7 +1130,7 @@ func TestFetchLatestMetadataOption(t *testing.T) {
11301130
for i := 1010; i < 1020; i++ {
11311131
req := tarantool.NewDeleteRequest(spaceName).
11321132
Key([]interface{}{uint(i)})
1133-
conn.Do(req).Get()
1133+
_, _ = conn.Do(req).Get()
11341134
}
11351135

11361136
resp := crud.Result{}
@@ -1147,7 +1147,7 @@ func TestFetchLatestMetadataOption(t *testing.T) {
11471147
for i := 1010; i < 1020; i++ {
11481148
req := tarantool.NewDeleteRequest(spaceName).
11491149
Key([]interface{}{uint(i)})
1150-
conn.Do(req).Get()
1150+
_, _ = conn.Do(req).Get()
11511151
}
11521152
})
11531153
}
@@ -1283,7 +1283,7 @@ func TestNoreturnOption(t *testing.T) {
12831283
for i := 1010; i < 1020; i++ {
12841284
req := tarantool.NewDeleteRequest(spaceName).
12851285
Key([]interface{}{uint(i)})
1286-
conn.Do(req).Get()
1286+
_, _ = conn.Do(req).Get()
12871287
}
12881288

12891289
data, err := conn.Do(testCase.req).Get()
@@ -1306,7 +1306,7 @@ func TestNoreturnOption(t *testing.T) {
13061306
for i := 1010; i < 1020; i++ {
13071307
req := tarantool.NewDeleteRequest(spaceName).
13081308
Key([]interface{}{uint(i)})
1309-
conn.Do(req).Get()
1309+
_, _ = conn.Do(req).Get()
13101310
}
13111311
})
13121312
}
@@ -1321,7 +1321,7 @@ func TestNoreturnOptionTyped(t *testing.T) {
13211321
for i := 1010; i < 1020; i++ {
13221322
req := tarantool.NewDeleteRequest(spaceName).
13231323
Key([]interface{}{uint(i)})
1324-
conn.Do(req).Get()
1324+
_, _ = conn.Do(req).Get()
13251325
}
13261326

13271327
resp := crud.Result{}
@@ -1342,7 +1342,7 @@ func TestNoreturnOptionTyped(t *testing.T) {
13421342
for i := 1010; i < 1020; i++ {
13431343
req := tarantool.NewDeleteRequest(spaceName).
13441344
Key([]interface{}{uint(i)})
1345-
conn.Do(req).Get()
1345+
_, _ = conn.Do(req).Get()
13461346
}
13471347
})
13481348
}

0 commit comments

Comments
 (0)