github-vet / github-vet/rangeloop-pointer-findings
racker/rackspace-monitoring-poller: config/config.go; 48 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [racker/rackspace-monitoring-poller](https://www.github.com/racker/rackspace-monitoring-poller) at [config/config.go](https://github.com/racker/rackspace-monitoring-poller/blob/d9d48e220a69544f1454521a7ae3ecdca31383ba/config/config.go#L283-L330)
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 entry was used in a composite literal at line 295
[Click here to see the code in its original context.](https://github.com/racker/rackspace-monitoring-poller/blob/d9d48e220a69544f1454521a7ae3ecdca31383ba/config/config.go#L283-L330)
Click here to show the 48 line(s) of Go which triggered the analyzer.
```go
for _, entry := range configEntries {
if entry.Name == fields[0] {
switch valuePtr := entry.ValuePtr.(type) {
case *string:
if err := entry.IsAllowed(fields[1]); err != nil {
return fmt.Errorf("Disallowed value in %s : %v", entry.Name, err)
}
*valuePtr = fields[1]
log.WithFields(log.Fields{
"prefix": prefix,
"name": entry.Name,
"value": ApplyMask(&entry, *valuePtr),
}).Debug("Setting configuration field")
case *[]string:
rawParts := strings.Split(fields[1], ",")
parts := make([]string, len(rawParts))
for i, p := range rawParts {
v := strings.TrimSpace(p)
if err := entry.IsAllowed(v); err != nil {
return fmt.Errorf("Disallowed value in %s : %v", entry.Name, err)
}
parts[i] = v
}
*valuePtr = parts
log.WithFields(log.Fields{
"prefix": prefix,
"name": entry.Name,
"value": ApplyMask(&entry, *valuePtr),
}).Debug("Setting configuration field")
case **url.URL:
// using ParseRequestURI rather than Parse since it is stricter about absolute URI or paths
parsed, err := url.ParseRequestURI(fields[1])
if err != nil {
return errors2.WithMessage(err, fmt.Sprintf("%s is not a valid URL", entry.Name))
}
*valuePtr = parsed
default:
return fmt.Errorf("Unsupported config entry type for %s", entry.Name)
}
if entry.Tweak != nil {
entry.Tweak()
}
}
}
```
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: d9d48e220a69544f1454521a7ae3ecdca31383ba
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.