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

appscode/service-broker: test/util/util.go; 11 LoC

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

Description

Found a possible issue in [appscode/service-broker](https://www.github.com/appscode/service-broker) at [test/util/util.go](https://github.com/appscode/service-broker/blob/4b22d1e2e4b0fe5189a4d618c405b640dd646370/test/util/util.go#L310-L320)

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 cond is reassigned at line 312

[Click here to see the code in its original context.](https://github.com/appscode/service-broker/blob/4b22d1e2e4b0fe5189a4d618c405b640dd646370/test/util/util.go#L310-L320)

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

```go
for _, cond := range binding.Status.Conditions {
if condition.Type == cond.Type {
lastSeenCondition = &cond
}
//if condition.Type == cond.Type && condition.Status == cond.Status {
if condition.Type == cond.Type {
if condition.Reason == "" || condition.Reason == cond.Reason {
return true, nil
}
}
}

```

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: 4b22d1e2e4b0fe5189a4d618c405b640dd646370

Contributor guide

No contributing guide indexed for this repository

Research direction

Read test/util/util.go around lines 310-320 and the linked original context, then assess how the range-loop reference affects lastSeenCondition and the surrounding condition checks. The contribution is complete when the finding is classified as Bug, Mitigated, or Desirable Behavior based on the code's intended behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
testing-qa
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.