Upgrade golangci-lint (#24707)

Signed-off-by: Enwei Jiao <enwei.jiao@zilliz.com>
pull/24729/head
Enwei Jiao 2023-06-07 19:34:36 +08:00 committed by GitHub
parent 89db828f71
commit d3af451d92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 83 additions and 72 deletions

View File

@ -26,6 +26,10 @@ linters:
# - gocritic
linters-settings:
revive:
rules:
- name: unused-parameter
disabled: true
misspell:
locale: US
gocritic:
@ -36,14 +40,19 @@ linters-settings:
failOnError: true
rules: 'rules.go'
depguard:
list-type: denylist
include-go-root: true
packages:
- errors
- github.com/pkg/errors
- github.com/pingcap/errors
- golang.org/x/xerrors
- github.com/go-errors/errors
rules:
main:
deny:
- pkg: 'errors'
desc: not allowd, use github.com/cockroachdb/errors
- pkg: 'github.com/pkg/errors'
desc: not allowd, use github.com/cockroachdb/errors
- pkg: 'github.com/pingcap/errors'
desc: not allowd, use github.com/cockroachdb/errors
- pkg: 'golang.org/x/xerrors'
desc: not allowd, use github.com/cockroachdb/errors
- pkg: 'github.com/go-errors/errors'
desc: not allowd, use github.com/cockroachdb/errors
forbidigo:
forbid:
- '^time\.Tick$'

View File

@ -49,7 +49,7 @@ get-build-deps:
# attention: upgrade golangci-lint should also change Dockerfiles in build/docker/builder/cpu/<os>
getdeps:
@mkdir -p $(INSTALL_PATH)
@$(INSTALL_PATH)/golangci-lint --version 2>&1 1>/dev/null || (echo "Installing golangci-lint into ./bin/" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(INSTALL_PATH) v1.46.2)
@$(INSTALL_PATH)/golangci-lint --version 2>&1 1>/dev/null || (echo "Installing golangci-lint into ./bin/" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(INSTALL_PATH) v1.53.1)
@$(INSTALL_PATH)/mockery --version 2>&1 1>/dev/null || (echo "Installing mockery v2.16.0 to ./bin/" && GOBIN=$(INSTALL_PATH)/ go install github.com/vektra/mockery/v2@v2.16.0)
tools/bin/revive: tools/check/go.mod

2
go.mod
View File

@ -29,7 +29,7 @@ require (
github.com/nats-io/nats.go v1.24.0
github.com/panjf2000/ants/v2 v2.7.2
github.com/prometheus/client_golang v1.14.0
github.com/quasilyte/go-ruleguard/dsl v0.3.21
github.com/quasilyte/go-ruleguard/dsl v0.3.22
github.com/samber/lo v1.27.0
github.com/sbinet/npyio v0.6.0
github.com/spf13/viper v1.8.1

4
go.sum
View File

@ -714,8 +714,8 @@ github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1
github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI=
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/quasilyte/go-ruleguard/dsl v0.3.21 h1:vNkC6fC6qMLzCOGbnIHOd5ixUGgTbp3Z4fGnUgULlDA=
github.com/quasilyte/go-ruleguard/dsl v0.3.21/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU=
github.com/quasilyte/go-ruleguard/dsl v0.3.22 h1:wd8zkOhSNr+I+8Qeciml08ivDt1pSXe60+5DqOpCjPE=
github.com/quasilyte/go-ruleguard/dsl v0.3.22/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU=
github.com/rivo/tview v0.0.0-20200219210816-cd38d7432498/go.mod h1:6lkG1x+13OShEf0EaOCaTQYyB7d5nSbb181KtjlS+84=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/clock v0.0.0-20190514195947-2896927a307a/go.mod h1:4r5QyqhjIWCcK8DO4KMclc5Iknq5qVBAlbYYzAbUScQ=

View File

@ -21,6 +21,7 @@ import (
"net/http"
"os"
"strconv"
"time"
"go.uber.org/zap"
@ -67,7 +68,8 @@ func ServeHTTP() {
go func() {
bindAddr := getHTTPAddr()
log.Info("management listen", zap.String("addr", bindAddr))
if err := http.ListenAndServe(bindAddr, nil); err != nil {
server := &http.Server{Addr: bindAddr, ReadTimeout: 10 * time.Second}
if err := server.ListenAndServe(); err != nil {
log.Error("handle metrics failed", zap.Error(err))
}
}()

View File

@ -29,6 +29,7 @@ type tsoAllocator interface {
}
// use timestampAllocatorInterface to keep other components testable
//
//go:generate mockery --name=timestampAllocatorInterface --filename=mock_tso_test.go --outpkg=proxy --output=. --inpackage --structname=mockTimestampAllocator --with-expecter
type timestampAllocatorInterface interface {
AllocTimestamp(ctx context.Context, req *rootcoordpb.AllocTimestampRequest) (*rootcoordpb.AllocTimestampResponse, error)

View File

@ -51,8 +51,8 @@ type mockTimestampAllocator_AllocTimestamp_Call struct {
}
// AllocTimestamp is a helper method to define mock.On call
// - ctx context.Context
// - req *rootcoordpb.AllocTimestampRequest
// - ctx context.Context
// - req *rootcoordpb.AllocTimestampRequest
func (_e *mockTimestampAllocator_Expecter) AllocTimestamp(ctx interface{}, req interface{}) *mockTimestampAllocator_AllocTimestamp_Call {
return &mockTimestampAllocator_AllocTimestamp_Call{Call: _e.mock.On("AllocTimestamp", ctx, req)}
}

View File

@ -24,7 +24,6 @@ var (
// RoundRobinPolicy do the query with multiple dml channels
// if request failed, it finds shard leader for failed dml channels
//
func RoundRobinPolicy(
ctx context.Context,
mgr *shardClientMgr,

View File

@ -46,7 +46,7 @@ type MockManager_GetWorker_Call struct {
}
// GetWorker is a helper method to define mock.On call
// - nodeID int64
// - nodeID int64
func (_e *MockManager_Expecter) GetWorker(nodeID interface{}) *MockManager_GetWorker_Call {
return &MockManager_GetWorker_Call{Call: _e.mock.On("GetWorker", nodeID)}
}

View File

@ -163,8 +163,8 @@ type MockShardDelegator_GetStatistics_Call struct {
}
// GetStatistics is a helper method to define mock.On call
// - ctx context.Context
// - req *querypb.GetStatisticsRequest
// - ctx context.Context
// - req *querypb.GetStatisticsRequest
func (_e *MockShardDelegator_Expecter) GetStatistics(ctx interface{}, req interface{}) *MockShardDelegator_GetStatistics_Call {
return &MockShardDelegator_GetStatistics_Call{Call: _e.mock.On("GetStatistics", ctx, req)}
}
@ -201,9 +201,9 @@ type MockShardDelegator_LoadGrowing_Call struct {
}
// LoadGrowing is a helper method to define mock.On call
// - ctx context.Context
// - infos []*querypb.SegmentLoadInfo
// - version int64
// - ctx context.Context
// - infos []*querypb.SegmentLoadInfo
// - version int64
func (_e *MockShardDelegator_Expecter) LoadGrowing(ctx interface{}, infos interface{}, version interface{}) *MockShardDelegator_LoadGrowing_Call {
return &MockShardDelegator_LoadGrowing_Call{Call: _e.mock.On("LoadGrowing", ctx, infos, version)}
}
@ -240,8 +240,8 @@ type MockShardDelegator_LoadSegments_Call struct {
}
// LoadSegments is a helper method to define mock.On call
// - ctx context.Context
// - req *querypb.LoadSegmentsRequest
// - ctx context.Context
// - req *querypb.LoadSegmentsRequest
func (_e *MockShardDelegator_Expecter) LoadSegments(ctx interface{}, req interface{}) *MockShardDelegator_LoadSegments_Call {
return &MockShardDelegator_LoadSegments_Call{Call: _e.mock.On("LoadSegments", ctx, req)}
}
@ -269,8 +269,8 @@ type MockShardDelegator_ProcessDelete_Call struct {
}
// ProcessDelete is a helper method to define mock.On call
// - deleteData []*DeleteData
// - ts uint64
// - deleteData []*DeleteData
// - ts uint64
func (_e *MockShardDelegator_Expecter) ProcessDelete(deleteData interface{}, ts interface{}) *MockShardDelegator_ProcessDelete_Call {
return &MockShardDelegator_ProcessDelete_Call{Call: _e.mock.On("ProcessDelete", deleteData, ts)}
}
@ -298,7 +298,7 @@ type MockShardDelegator_ProcessInsert_Call struct {
}
// ProcessInsert is a helper method to define mock.On call
// - insertRecords map[int64]*InsertData
// - insertRecords map[int64]*InsertData
func (_e *MockShardDelegator_Expecter) ProcessInsert(insertRecords interface{}) *MockShardDelegator_ProcessInsert_Call {
return &MockShardDelegator_ProcessInsert_Call{Call: _e.mock.On("ProcessInsert", insertRecords)}
}
@ -344,8 +344,8 @@ type MockShardDelegator_Query_Call struct {
}
// Query is a helper method to define mock.On call
// - ctx context.Context
// - req *querypb.QueryRequest
// - ctx context.Context
// - req *querypb.QueryRequest
func (_e *MockShardDelegator_Expecter) Query(ctx interface{}, req interface{}) *MockShardDelegator_Query_Call {
return &MockShardDelegator_Query_Call{Call: _e.mock.On("Query", ctx, req)}
}
@ -382,9 +382,9 @@ type MockShardDelegator_ReleaseSegments_Call struct {
}
// ReleaseSegments is a helper method to define mock.On call
// - ctx context.Context
// - req *querypb.ReleaseSegmentsRequest
// - force bool
// - ctx context.Context
// - req *querypb.ReleaseSegmentsRequest
// - force bool
func (_e *MockShardDelegator_Expecter) ReleaseSegments(ctx interface{}, req interface{}, force interface{}) *MockShardDelegator_ReleaseSegments_Call {
return &MockShardDelegator_ReleaseSegments_Call{Call: _e.mock.On("ReleaseSegments", ctx, req, force)}
}
@ -430,8 +430,8 @@ type MockShardDelegator_Search_Call struct {
}
// Search is a helper method to define mock.On call
// - ctx context.Context
// - req *querypb.SearchRequest
// - ctx context.Context
// - req *querypb.SearchRequest
func (_e *MockShardDelegator_Expecter) Search(ctx interface{}, req interface{}) *MockShardDelegator_Search_Call {
return &MockShardDelegator_Search_Call{Call: _e.mock.On("Search", ctx, req)}
}
@ -529,8 +529,8 @@ type MockShardDelegator_SyncDistribution_Call struct {
}
// SyncDistribution is a helper method to define mock.On call
// - ctx context.Context
// - entries ...SegmentEntry
// - ctx context.Context
// - entries ...SegmentEntry
func (_e *MockShardDelegator_Expecter) SyncDistribution(ctx interface{}, entries ...interface{}) *MockShardDelegator_SyncDistribution_Call {
return &MockShardDelegator_SyncDistribution_Call{Call: _e.mock.On("SyncDistribution",
append([]interface{}{ctx}, entries...)...)}

View File

@ -38,7 +38,7 @@ type deleteNode struct {
delegator delegator.ShardDelegator
}
//addDeleteData find the segment of delete column in DeleteMsg and save in deleteData
// addDeleteData find the segment of delete column in DeleteMsg and save in deleteData
func (dNode *deleteNode) addDeleteData(deleteDatas map[UniqueID]*delegator.DeleteData, msg *DeleteMsg) {
deleteData, ok := deleteDatas[msg.PartitionID]
if !ok {

View File

@ -31,7 +31,7 @@ import (
"github.com/milvus-io/milvus/pkg/util/typeutil"
)
//test of filter node
// test of filter node
type FilterNodeSuite struct {
suite.Suite
//datas
@ -74,7 +74,7 @@ func (suite *FilterNodeSuite) SetupSuite() {
}
}
//test filter node with collection load collection
// test filter node with collection load collection
func (suite *FilterNodeSuite) TestWithLoadCollection() {
//data
suite.validSegmentIDs = []int64{2, 3, 4, 5, 6}
@ -109,7 +109,7 @@ func (suite *FilterNodeSuite) TestWithLoadCollection() {
suite.Equal(suite.deleteSegmentSum, len(nodeMsg.deleteMsgs))
}
//test filter node with collection load partition
// test filter node with collection load partition
func (suite *FilterNodeSuite) TestWithLoadPartation() {
//data
suite.validSegmentIDs = []int64{2, 3, 4, 5, 6}

View File

@ -29,7 +29,7 @@ import (
"github.com/milvus-io/milvus/pkg/util/typeutil"
)
//pipeline used for querynode
// pipeline used for querynode
type Pipeline interface {
base.StreamPipeline
ExcludedSegments(segInfos ...*datapb.SegmentInfo)

View File

@ -65,11 +65,11 @@ type MockLoader_Load_Call struct {
}
// Load is a helper method to define mock.On call
// - ctx context.Context
// - collectionID int64
// - segmentType commonpb.SegmentState
// - version int64
// - infos ...*querypb.SegmentLoadInfo
// - ctx context.Context
// - collectionID int64
// - segmentType commonpb.SegmentState
// - version int64
// - infos ...*querypb.SegmentLoadInfo
func (_e *MockLoader_Expecter) Load(ctx interface{}, collectionID interface{}, segmentType interface{}, version interface{}, infos ...interface{}) *MockLoader_Load_Call {
return &MockLoader_Load_Call{Call: _e.mock.On("Load",
append([]interface{}{ctx, collectionID, segmentType, version}, infos...)...)}
@ -129,10 +129,10 @@ type MockLoader_LoadBloomFilterSet_Call struct {
}
// LoadBloomFilterSet is a helper method to define mock.On call
// - ctx context.Context
// - collectionID int64
// - version int64
// - infos ...*querypb.SegmentLoadInfo
// - ctx context.Context
// - collectionID int64
// - version int64
// - infos ...*querypb.SegmentLoadInfo
func (_e *MockLoader_Expecter) LoadBloomFilterSet(ctx interface{}, collectionID interface{}, version interface{}, infos ...interface{}) *MockLoader_LoadBloomFilterSet_Call {
return &MockLoader_LoadBloomFilterSet_Call{Call: _e.mock.On("LoadBloomFilterSet",
append([]interface{}{ctx, collectionID, version}, infos...)...)}
@ -176,9 +176,9 @@ type MockLoader_LoadDeltaLogs_Call struct {
}
// LoadDeltaLogs is a helper method to define mock.On call
// - ctx context.Context
// - segment *LocalSegment
// - deltaLogs []*datapb.FieldBinlog
// - ctx context.Context
// - segment *LocalSegment
// - deltaLogs []*datapb.FieldBinlog
func (_e *MockLoader_Expecter) LoadDeltaLogs(ctx interface{}, segment interface{}, deltaLogs interface{}) *MockLoader_LoadDeltaLogs_Call {
return &MockLoader_LoadDeltaLogs_Call{Call: _e.mock.On("LoadDeltaLogs", ctx, segment, deltaLogs)}
}

View File

@ -37,8 +37,8 @@ type MockSegment_AddIndex_Call struct {
}
// AddIndex is a helper method to define mock.On call
// - fieldID int64
// - index *IndexedFieldInfo
// - fieldID int64
// - index *IndexedFieldInfo
func (_e *MockSegment_Expecter) AddIndex(fieldID interface{}, index interface{}) *MockSegment_AddIndex_Call {
return &MockSegment_AddIndex_Call{Call: _e.mock.On("AddIndex", fieldID, index)}
}
@ -111,8 +111,8 @@ type MockSegment_Delete_Call struct {
}
// Delete is a helper method to define mock.On call
// - primaryKeys []storage.PrimaryKey
// - timestamps []uint64
// - primaryKeys []storage.PrimaryKey
// - timestamps []uint64
func (_e *MockSegment_Expecter) Delete(primaryKeys interface{}, timestamps interface{}) *MockSegment_Delete_Call {
return &MockSegment_Delete_Call{Call: _e.mock.On("Delete", primaryKeys, timestamps)}
}
@ -149,7 +149,7 @@ type MockSegment_ExistIndex_Call struct {
}
// ExistIndex is a helper method to define mock.On call
// - fieldID int64
// - fieldID int64
func (_e *MockSegment_Expecter) ExistIndex(fieldID interface{}) *MockSegment_ExistIndex_Call {
return &MockSegment_ExistIndex_Call{Call: _e.mock.On("ExistIndex", fieldID)}
}
@ -188,7 +188,7 @@ type MockSegment_GetIndex_Call struct {
}
// GetIndex is a helper method to define mock.On call
// - fieldID int64
// - fieldID int64
func (_e *MockSegment_Expecter) GetIndex(fieldID interface{}) *MockSegment_GetIndex_Call {
return &MockSegment_GetIndex_Call{Call: _e.mock.On("GetIndex", fieldID)}
}
@ -299,9 +299,9 @@ type MockSegment_Insert_Call struct {
}
// Insert is a helper method to define mock.On call
// - rowIDs []int64
// - timestamps []uint64
// - record *segcorepb.InsertRecord
// - rowIDs []int64
// - timestamps []uint64
// - record *segcorepb.InsertRecord
func (_e *MockSegment_Expecter) Insert(rowIDs interface{}, timestamps interface{}, record interface{}) *MockSegment_Insert_Call {
return &MockSegment_Insert_Call{Call: _e.mock.On("Insert", rowIDs, timestamps, record)}
}
@ -410,7 +410,7 @@ type MockSegment_MayPkExist_Call struct {
}
// MayPkExist is a helper method to define mock.On call
// - pk storage.PrimaryKey
// - pk storage.PrimaryKey
func (_e *MockSegment_Expecter) MayPkExist(pk interface{}) *MockSegment_MayPkExist_Call {
return &MockSegment_MayPkExist_Call{Call: _e.mock.On("MayPkExist", pk)}
}
@ -656,7 +656,7 @@ type MockSegment_UpdateBloomFilter_Call struct {
}
// UpdateBloomFilter is a helper method to define mock.On call
// - pks []storage.PrimaryKey
// - pks []storage.PrimaryKey
func (_e *MockSegment_Expecter) UpdateBloomFilter(pks interface{}) *MockSegment_UpdateBloomFilter_Call {
return &MockSegment_UpdateBloomFilter_Call{Call: _e.mock.On("UpdateBloomFilter", pks)}
}

View File

@ -28,12 +28,13 @@ import "C"
import (
"context"
"fmt"
"github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus/pkg/util/funcutil"
"sort"
"sync"
"unsafe"
"github.com/milvus-io/milvus/pkg/common"
"github.com/milvus-io/milvus/pkg/util/funcutil"
"github.com/cockroachdb/errors"
"github.com/golang/protobuf/proto"
"go.opentelemetry.io/otel/trace"

View File

@ -41,7 +41,7 @@ func (suite *TSafeTestSuite) SetupTest() {
suite.tSafeReplica = NewTSafeReplica()
}
//test Basic use of TSafeReplica
// test Basic use of TSafeReplica
func (suite *TSafeTestSuite) TestBasic() {
suite.tSafeReplica.Add(suite.channel, ZeroTimestamp)
t, err := suite.tSafeReplica.Get(suite.channel)

View File

@ -31,6 +31,7 @@ func NewMinioClient(address string, opts *minio.Options) (*minio.Client, error)
}
// Credential is defined to mock aliyun credential.Credentials
//
//go:generate mockery --name=Credential --with-expecter
type Credential interface {
credentials.Credential

View File

@ -1320,9 +1320,7 @@ func (dataDefinitionCodec *DataDefinitionCodec) Deserialize(blobs []*Blob) (ts [
binlogReader.Close()
return nil, nil, err
}
for idx := range stringPayload {
requestsStrings = append(requestsStrings, stringPayload[idx])
}
requestsStrings = append(requestsStrings, stringPayload...)
}
eventReader.Close()
}

View File

@ -104,7 +104,7 @@ func (node *BaseNode) Name() string {
return node.name
}
//length of pipeline input chnnel
// length of pipeline input chnnel
func (node *BaseNode) MaxQueueLength() int32 {
return node.maxQueueLength
}

View File

@ -6,7 +6,7 @@
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,