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

open-integration/oictl: cmd/generate_service.go; 40 LoC

Open
#15,191 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 [open-integration/oictl](https://www.github.com/open-integration/oictl) at [cmd/generate_service.go](https://github.com/open-integration/oictl/blob/0a8c304f3416c1d669b0f0dd68010bdee58b7991/cmd/generate_service.go#L90-L129)

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 ep was used in a composite literal at line 97

[Click here to see the code in its original context.](https://github.com/open-integration/oictl/blob/0a8c304f3416c1d669b0f0dd68010bdee58b7991/cmd/generate_service.go#L90-L129)

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

```go
for _, ep := range svc.Endpoints {
if templateMeta.Endpoint == nil {
log.Debug("Endpoint is not configured")
continue
}
tasks = append(tasks, task.RenderTask{
Name: fmt.Sprintf("Generate endpont.go"),
Data: buildEndpointData(&ep, rootScopedData, log),
Directory: workingDir,
Logger: log,
Overwrite: false,
IDs: map[string]string{
templateMeta.Endpoint.Template.File: templateMeta.Endpoint.Template.String,
},
})

tasks = append(tasks, task.RenderTask{
Name: fmt.Sprintf("Generate arguments.json"),
Data: buildEndpointData(&ep, rootScopedData, log),
Directory: workingDir,
Logger: log,
Overwrite: false,
IDs: map[string]string{
templateMeta.Endpoint.Arguments.File: templateMeta.Endpoint.Arguments.String,
},
PostCommands: templateMeta.Endpoint.Arguments.Post,
})

tasks = append(tasks, task.RenderTask{
Name: fmt.Sprintf("Generate returns.json"),
Data: buildEndpointData(&ep, rootScopedData, log),
Directory: workingDir,
Logger: log,
Overwrite: false,
IDs: map[string]string{
templateMeta.Endpoint.Returns.File: templateMeta.Endpoint.Returns.String,
},
PostCommands: templateMeta.Endpoint.Returns.Post,
})
}

```

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: 0a8c304f3416c1d669b0f0dd68010bdee58b7991

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.