github-vet / github-vet/rangeloop-pointer-findings
DavidGamba/dgtools: ffind/lib/ffind/ffind.go; 59 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [DavidGamba/dgtools](https://www.github.com/DavidGamba/dgtools) at [ffind/lib/ffind/ffind.go](https://github.com/DavidGamba/dgtools/blob/c5d1de550df8186842ccad442f88c842e8e05fb8/ffind/lib/ffind/ffind.go#L196-L254)
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 e is reassigned at line 205
[Click here to see the code in its original context.](https://github.com/DavidGamba/dgtools/blob/c5d1de550df8186842ccad442f88c842e8e05fb8/ffind/lib/ffind/ffind.go#L196-L254)
Click here to show the 59 line(s) of Go which triggered the analyzer.
```go
for e := range ch {
logger.Printf("\tReceived: %s", e.FileInfo.Name())
if e.Error != nil {
logger.Printf("\tError received: %s", e.Error)
c <- e
continue
}
// Check if file is symlink.
ne := &e
checkSymlink := func() {
if e.IsSymlink() && follow {
logger.Printf("\tIsSymlink: %s", e.Path)
eval, err := filepath.EvalSymlinks(e.Path)
if err != nil {
logger.Printf("\tEvalSymlinks error: %s", err)
// If the link is broken then just return the original file
if os.IsNotExist(err) {
return
}
e.Error = err
return
}
ne, err = NewFileError(eval)
if err != nil {
logger.Printf("\tNew Error received: %s", err)
e.Error = err
return
}
logger.Printf("\tSymlink: %s", ne.Path)
}
}
checkSymlink()
if ne.FileInfo.IsDir() {
// TODO: Make sure to test SkipDirName
if s.SkipDirName(e.FileInfo.Name()) {
continue
}
if !s.SkipDirResults() {
logger.Printf("DIR: %s - %s", e.Path, ne.Path)
c <- e
}
cr := listRecursive(&e, follow, s, sortFn)
for e := range cr {
logger.Printf("Recurse: %s", e.Path)
c <- e
}
} else {
// TODO: Make sure to test SkipFileName
if s.SkipFileResults() || s.SkipFileName(e.FileInfo.Name()) {
continue
}
logger.Printf("Else: %s", e.Path)
if s.MatchFileName(e.FileInfo.Name()) {
c <- e
}
}
}
```
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: c5d1de550df8186842ccad442f88c842e8e05fb8
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.