apache / dubbo-go

Go Implementation For Apache Dubbo .
https://dubbo.apache.org/
Apache License 2.0
4.67k stars 910 forks source link

fix: fix miss makezero bug #2682

Closed alingse closed 1 month ago

alingse commented 1 month ago

I was running github actions to run linter makezero for top github golang repos.

see issues https://github.com/alingse/go-linter-runner/issues/1

and the github actions output https://github.com/alingse/go-linter-runner/actions/runs/9242652074/job/25425741161

====================================================================================================
append to slice `vhs` with non-zero initialized length at https://github.com/apache/dubbo-go/blob/main/xds/client/resource/filter_chain.go#L119:9
append to slice `keyList` with non-zero initialized length at https://github.com/apache/dubbo-go/blob/main/protocol/dubbo3/dubbo3_protocol.go#L156:13
append to slice `in` with non-zero initialized length at https://github.com/apache/dubbo-go/blob/main/proxy/proxy_factory/pass_through.go#L[10](https://github.com/alingse/go-linter-runner/actions/runs/9242652074/job/25425741161#step:4:11)5:7
append to slice `in` with non-zero initialized length at https://github.com/apache/dubbo-go/blob/main/proxy/proxy_factory/pass_through.go#L106:7
append to slice `in` with non-zero initialized length at https://github.com/apache/dubbo-go/blob/main/proxy/proxy_factory/pass_through.go#L107:7
append to slice `in` with non-zero initialized length at https://github.com/apache/dubbo-go/blob/main/proxy/proxy_factory/pass_through.go#L108:7
append to slice `in` with non-zero initialized length at https://github.com/apache/dubbo-go/blob/main/proxy/proxy_factory/pass_through.go#L109:7
append to slice `subInstances` with non-zero initialized length at https://github.com/apache/dubbo-go/blob/main/registry/servicediscovery/service_instances_changed_listener_impl.go#L[11](https://github.com/alingse/go-linter-runner/actions/runs/9242652074/job/25425741161#step:4:12)9:36
====================================================================================================

the vhs , keyList , subInstances is easy to check that they are bugs and they need make the slice to zero length.

but the other lines has var in that linter reported, I don't know if they are some special usage, so I wasn't commit them.

    in := make([]reflect.Value, 5) // maybe should replace with  in := make([]reflect.Value, 0, 5)
    in = append(in, srv.Rcvr())
    in = append(in, reflect.ValueOf(invocation.MethodName()))
    in = append(in, reflect.ValueOf(invocation.GetAttachmentInterface(constant.ParamsTypeKey)))
    in = append(in, reflect.ValueOf(args))
    in = append(in, reflect.ValueOf(invocation.Attachments()))
sonarcloud[bot] commented 1 month ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud