github-vet / github-vet/rangeloop-pointer-findings

kubesphere/notification-manager: adapter/sink/cmd/types.go; 10 LoC

Open
#14,379 0 comments 0 reactions 0 assignees View on GitHub
fresh tiny
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [kubesphere/notification-manager](https://www.github.com/kubesphere/notification-manager) at [adapter/sink/cmd/types.go](https://github.com/kubesphere/notification-manager/blob/1f653636d4dc48bbc98a618a5b1e6579bba69188/adapter/sink/cmd/types.go#L44-L53)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.

> reference to a was used in a composite literal at line 49

[Click here to see the code in its original context.](https://github.com/kubesphere/notification-manager/blob/1f653636d4dc48bbc98a618a5b1e6579bba69188/adapter/sink/cmd/types.go#L44-L53)

Click here to show the 10 line(s) of Go which triggered the analyzer.

```go
for _, a := range d.Alerts {
for k, v := range d.CommonLabels {
a.Labels[k] = v
}
alert := Alert{
&a,
&TraceInfo{ReceivedTime: time.Now()},
}
as = append(as, &alert)
}

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: 1f653636d4dc48bbc98a618a5b1e6579bba69188

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with adapter/sink/cmd/types.go lines 44-53 and review the range loop, the Alert composite literal, and the analyzer’s range-loop pointer finding. Check the referenced commit and project context to determine whether the pointer behavior is a bug, mitigated, or desirable, then leave the corresponding reaction as requested.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.