Skip to content

Commit 989b7af

Browse files
committed
internal: enable tparallel, predeclared, nilnil
The codebase had patterns flagged by disabled linters: tests missing t.Parallel() at the top level, a parameter shadowing the predeclared identifier 'len', and functions returning both a nil value and a nil error. Enable these linters and fix the reported issues to prevent regressions and improve code quality.
1 parent dbac90b commit 989b7af

5 files changed

Lines changed: 20 additions & 17 deletions

File tree

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,16 @@ linters:
5151
- maintidx
5252
- mnd
5353
- nestif
54-
- nilnil
5554
- nlreturn
5655
- noctx
5756
- noinlineerr
5857
- nonamedreturns
5958
- paralleltest
6059
- perfsprint
6160
- prealloc
62-
- predeclared
6361
- recvcheck
6462
- revive
6563
- staticcheck
66-
- tparallel
6764
- testableexamples
6865
- testpackage
6966
- unqueryvet

box/schema_user_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
)
1616

1717
func TestUserExistsResponse_DecodeMsgpack(t *testing.T) {
18+
t.Parallel()
19+
1820
tCases := map[bool]func() *bytes.Buffer{
1921
true: func() *bytes.Buffer {
2022
buf := bytes.NewBuffer(nil)
@@ -47,6 +49,8 @@ func TestUserExistsResponse_DecodeMsgpack(t *testing.T) {
4749
}
4850

4951
func TestUserPasswordResponse_DecodeMsgpack(t *testing.T) {
52+
t.Parallel()
53+
5054
tCases := []string{
5155
"test",
5256
"$tr0ng_pass",

client_tools.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ func (ops *Operations) append(op string, field int, arg any) *Operations {
144144
return ops
145145
}
146146

147-
func (ops *Operations) appendSplice(op string, field, pos, len int, replace string) *Operations {
148-
ops.ops = append(ops.ops, operation{Op: op, Field: field, Pos: pos, Len: len, Replace: replace})
147+
func (ops *Operations) appendSplice(op string, field, pos, length int, replace string) *Operations {
148+
ops.ops = append(ops.ops, operation{Op: op, Field: field, Pos: pos, Len: length, Replace: replace})
149149
return ops
150150
}
151151

@@ -175,8 +175,8 @@ func (ops *Operations) BitwiseXor(field int, arg any) *Operations {
175175
}
176176

177177
// Splice adds a splice operation to the collection of update operations.
178-
func (ops *Operations) Splice(field, pos, len int, replace string) *Operations {
179-
return ops.appendSplice(spliceOperator, field, pos, len, replace)
178+
func (ops *Operations) Splice(field, pos, length int, replace string) *Operations {
179+
return ops.appendSplice(spliceOperator, field, pos, length, replace)
180180
}
181181

182182
// Insert adds an insert operation to the collection of update operations.

crud/tarantool_test.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -471,30 +471,30 @@ func generateObjectsOperationsData(objs []crud.Object,
471471
return objectsOperationsData
472472
}
473473

474-
func getCrudError(req tarantool.Request, crudError any) (any, error) {
474+
func getCrudError(req tarantool.Request, crudError any) error {
475475
var err []any
476476
var ok bool
477477

478478
rtype := req.Type()
479479
if crudError != nil {
480480
if rtype == iproto.IPROTO_CALL {
481-
return crudError, nil
481+
return fmt.Errorf("CRUD error: %v", crudError)
482482
}
483483

484484
if err, ok = crudError.([]any); !ok {
485-
return nil, fmt.Errorf("Incorrect CRUD error format")
485+
return fmt.Errorf("incorrect CRUD error format")
486486
}
487487

488488
if len(err) < 1 {
489-
return nil, fmt.Errorf("Incorrect CRUD error format")
489+
return fmt.Errorf("incorrect CRUD error format")
490490
}
491491

492492
if err[0] != nil {
493-
return err[0], nil
493+
return fmt.Errorf("CRUD error: %v", err[0])
494494
}
495495
}
496496

497-
return nil, nil
497+
return nil
498498
}
499499

500500
func testCrudRequestPrepareData(t *testing.T, conn tarantool.Connector) {
@@ -532,9 +532,8 @@ func testCrudRequestCheck(t *testing.T, req tarantool.Request,
532532
// resp.Data[0] - CRUD res.
533533
// resp.Data[1] - CRUD err.
534534
if expectedLen >= 2 && data[1] != nil {
535-
crudErr, getErr := getCrudError(req, data[1])
536-
require.NoError(t, getErr, "Failed to get CRUD error")
537-
require.Nil(t, crudErr, "Failed to perform CRUD request on CRUD side")
535+
crudErr := getCrudError(req, data[1])
536+
require.NoError(t, crudErr, "Failed to perform CRUD request on CRUD side")
538537
}
539538
}
540539

queue/queue.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
package queue
1010

1111
import (
12+
"errors"
1213
"fmt"
1314
"time"
1415

@@ -18,6 +19,8 @@ import (
1819
"github.com/tarantool/go-tarantool/v3"
1920
)
2021

22+
var ErrEmptyStatistic = errors.New("empty statistic response")
23+
2124
// Queue is a handle to Tarantool queue's tube.
2225
type Queue interface {
2326
// Set queue settings.
@@ -439,7 +442,7 @@ func (q *queue) Statistic() (any, error) {
439442
return data[0], nil
440443
}
441444

442-
return nil, nil
445+
return nil, ErrEmptyStatistic
443446
}
444447

445448
func makeCmd(q *queue) {

0 commit comments

Comments
 (0)