Copilot commented on code in PR #2902:
URL: https://github.com/apache/dubbo-go/pull/2902#discussion_r2114913400
##########
cluster/router/condition/route.go:
##########
@@ -372,7 +372,7 @@ func (s *destSets) randDest() *destination {
if len(s.destinations) == 1 {
return s.destinations[0]
}
- sum := rand.Intn(s.weightSum)
+ sum := rand.Intn(s.weightSum) //NOSONAR
Review Comment:
Add a short comment explaining why cryptographically secure random numbers
are unnecessary for weighted destination selection to improve clarity.
##########
protocol/triple/triple_protocol/triple_ext_test.go:
##########
@@ -544,7 +544,7 @@ func TestConcurrentStreams(t *testing.T) {
assert.Nil(t, err)
start.Wait()
for i := 0; i < 100; i++ {
- num := rand.Int63n(1000) //nolint: gosec
+ num := rand.Int63n(1000) //nolint: gosec
//NOSONAR
Review Comment:
[nitpick] Consider unifying linter suppressions by using a single standard
comment (e.g., `//nolint:gosec`) and include a brief rationale to clarify that
non-crypto randomness is acceptable here.
```suggestion
num := rand.Int63n(1000) //nolint:gosec //
Non-crypto randomness is used for testing purposes only.
```
##########
cluster/loadbalance/iwrr/iwrr.go:
##########
@@ -83,7 +83,7 @@ func NewInterleavedweightedRoundRobin(invokers
[]base.Invoker, invocation base.I
iwrrp.next = NewIwrrQueue()
size := uint64(len(invokers))
- offset := rand.Uint64() % size
+ offset := rand.Uint64() % size //NOSONAR
Review Comment:
Please document why math/rand is sufficient for computing the offset here,
so future maintainers understand that crypto/rand is not required.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]