github-vet / github-vet/rangeloop-pointer-findings
amsokol/protoc-gen-gotagger: pkg/tagger/golang.go; 23 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [amsokol/protoc-gen-gotagger](https://www.github.com/amsokol/protoc-gen-gotagger) at [pkg/tagger/golang.go](https://github.com/amsokol/protoc-gen-gotagger/blob/986f7f031f7e58261743e24179221f68a9ec4bcb/pkg/tagger/golang.go#L88-L110)
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 name was used in a composite literal at line 107
[Click here to see the code in its original context.](https://github.com/amsokol/protoc-gen-gotagger/blob/986f7f031f7e58261743e24179221f68a9ec4bcb/pkg/tagger/golang.go#L88-L110)
Click here to show the 23 line(s) of Go which triggered the analyzer.
```go
for name, file := range p.targetFiles {
path := p.outputPath + "/" + name
f, err := parser.ParseFile(fset, path, nil, parser.ParseComments)
if err != nil {
return fmt.Errorf("failed parse Go file '%s': %s", path, err.Error())
}
if err = updateTags(f, file.structs); err != nil {
return fmt.Errorf("failed to update tags in Go file '%s': %s", path, err.Error())
}
var buf bytes.Buffer
if err = format.Node(&buf, fset, f); err != nil {
return fmt.Errorf("failed to store updated Go file '%s': %s", path, err.Error())
}
content := buf.String()
p.response.File = append(p.response.File, &plugin_go.CodeGeneratorResponse_File{
Name: &name,
Content: &content,
})
}
```
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: 986f7f031f7e58261743e24179221f68a9ec4bcb
Contributor guide
No contributing guide indexed for this repository
Research direction
Inspect pkg/tagger/golang.go around lines 88-110, focusing on the range over p.targetFiles and the generated response entry. Determine whether the reference to name can produce incorrect behavior, then leave the requested reaction marking it Bug, Mitigated, or Desirable Behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100