未验证 提交 f2575e5f 编写于 作者: C congqixia 提交者: GitHub

Add unconvert & durationcheck linters and fix issues (#22161)

Signed-off-by: NCongqi Xia <congqi.xia@zilliz.com>
上级 5351fee7
......@@ -19,6 +19,8 @@ linters:
- gosimple
- gosec
- revive
- durationcheck
- unconvert
# - gocritic
linters-settings:
......
......@@ -298,7 +298,7 @@ func (c *mockDataNodeClient) ShowConfigurations(ctx context.Context, req *intern
func (c *mockDataNodeClient) GetMetrics(ctx context.Context, req *milvuspb.GetMetricsRequest) (*milvuspb.GetMetricsResponse, error) {
// TODO(dragondriver): change the id, though it's not important in ut
nodeID := UniqueID(c.id)
nodeID := c.id
nodeInfos := metricsinfo.DataNodeInfos{
BaseComponentInfos: metricsinfo.BaseComponentInfos{
......
......@@ -796,7 +796,7 @@ func Test_parseBinlogKey(t *testing.T) {
func verifyBinlogs(t *testing.T, binlogBytes []byte) {
binlogs := &datapb.FieldBinlog{}
err := proto.Unmarshal([]byte(binlogBytes), binlogs)
err := proto.Unmarshal(binlogBytes, binlogs)
assert.NoError(t, err)
assert.Equal(t, 1, len(binlogs.Binlogs))
assert.Equal(t, int64(99), binlogs.Binlogs[0].GetLogID())
......
......@@ -403,9 +403,9 @@ func TestRocksmq_Dummy(t *testing.T) {
assert.Error(t, err)
channelName2 := strings.Repeat(channelName1, 100)
err = rmq.CreateTopic(string(channelName2))
err = rmq.CreateTopic(channelName2)
assert.NoError(t, err)
_, err = rmq.Produce(string(channelName2), nil)
_, err = rmq.Produce(channelName2, nil)
assert.Error(t, err)
channelName3 := "channel/dummy"
......@@ -950,7 +950,7 @@ func TestRocksmq_GetLatestMsg(t *testing.T) {
assert.Nil(t, err)
msgID, err := rmq.GetLatestMsg(channelName)
assert.Equal(t, msgID, int64(DefaultMessageID))
assert.Equal(t, msgID, DefaultMessageID)
assert.Nil(t, err)
loopNum := 10
......@@ -990,7 +990,7 @@ func TestRocksmq_GetLatestMsg(t *testing.T) {
rmq.DestroyTopic(channelName)
rmq.Close()
msgID, err = rmq.GetLatestMsg(channelName)
assert.Equal(t, msgID, int64(DefaultMessageID))
assert.Equal(t, msgID, DefaultMessageID)
assert.NotNil(t, err)
}
......
......@@ -2270,7 +2270,7 @@ func (node *Proxy) Upsert(ctx context.Context, request *milvuspb.UpsertRequest)
req: &milvuspb.UpsertRequest{
Base: commonpbutil.NewMsgBase(
commonpbutil.WithMsgType(commonpb.MsgType(commonpb.MsgType_Upsert)),
commonpbutil.WithMsgType(commonpb.MsgType_Upsert),
commonpbutil.WithSourceID(paramtable.GetNodeID()),
),
CollectionName: request.CollectionName,
......
......@@ -634,8 +634,8 @@ func parseGuaranteeTs(ts, tMax typeutil.Timestamp) typeutil.Timestamp {
case strongTS:
ts = tMax
case boundedTS:
ratio := time.Duration(-Params.CommonCfg.GracefulTime.GetAsInt64())
ts = tsoutil.AddPhysicalDurationOnTs(tMax, ratio*time.Millisecond)
ratio := Params.CommonCfg.GracefulTime.GetAsDuration(time.Millisecond)
ts = tsoutil.AddPhysicalDurationOnTs(tMax, -ratio)
}
return ts
}
......
......@@ -70,8 +70,8 @@ func HandleCProto(cRes *C.CProto, msg proto.Message) error {
// CopyCProtoBlob returns the copy of C memory
func CopyCProtoBlob(cProto *C.CProto) []byte {
blob := C.GoBytes(unsafe.Pointer(cProto.proto_blob), C.int32_t(cProto.proto_size))
C.free(unsafe.Pointer(cProto.proto_blob))
blob := C.GoBytes(cProto.proto_blob, C.int32_t(cProto.proto_size))
C.free(cProto.proto_blob)
return blob
}
......
......@@ -90,7 +90,7 @@ func reduceSearchResultsAndFillData(plan *SearchPlan, searchResults []*SearchRes
}
cSearchResults = append(cSearchResults, res.cSearchResult)
}
cSearchResultPtr := (*C.CSearchResult)(&cSearchResults[0])
cSearchResultPtr := &cSearchResults[0]
cNumSegments := C.int64_t(numSegments)
var cSliceNQSPtr = (*C.int64_t)(&sliceNQs[0])
var cSliceTopKSPtr = (*C.int64_t)(&sliceTopKs[0])
......
......@@ -1293,7 +1293,7 @@ func TestNewBinlogReaderError(t *testing.T) {
assert.NotNil(t, err)
buffer := new(bytes.Buffer)
err = binary.Write(buffer, common.Endian, int32(MagicNumber))
err = binary.Write(buffer, common.Endian, MagicNumber)
assert.Nil(t, err)
data = buffer.Bytes()
......
......@@ -503,12 +503,12 @@ func getTypeName(dt schemapb.DataType) string {
func pkToShard(pk interface{}, shardNum uint32) (uint32, error) {
var shard uint32
strPK, ok := interface{}(pk).(string)
strPK, ok := pk.(string)
if ok {
hash := typeutil.HashString2Uint32(strPK)
shard = hash % shardNum
} else {
intPK, ok := interface{}(pk).(int64)
intPK, ok := pk.(int64)
if !ok {
log.Error("Numpy parser: primary key field must be int64 or varchar")
return 0, fmt.Errorf("primary key field must be int64 or varchar")
......
......@@ -634,7 +634,7 @@ func (w *sessionWatcher) handleWatchResponse(wresp clientv3.WatchResponse) {
case mvccpb.PUT:
log.Debug("watch services",
zap.Any("add kv", ev.Kv))
err := json.Unmarshal([]byte(ev.Kv.Value), session)
err := json.Unmarshal(ev.Kv.Value, session)
if err != nil {
log.Error("watch services", zap.Error(err))
continue
......@@ -650,7 +650,7 @@ func (w *sessionWatcher) handleWatchResponse(wresp clientv3.WatchResponse) {
case mvccpb.DELETE:
log.Debug("watch services",
zap.Any("delete kv", ev.PrevKv))
err := json.Unmarshal([]byte(ev.PrevKv.Value), session)
err := json.Unmarshal(ev.PrevKv.Value, session)
if err != nil {
log.Error("watch services", zap.Error(err))
continue
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册