mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-01 05:24:22 +01:00
Fix G307 warning: Deferring unsafe method "Close" on type "*os.File" (#1154)
* fix: check potential error from file.Close * fix(detect): use existing logger
This commit is contained in:
1 parent
bd8b145bea
commit
81cf30855c
1 file changed
+6
-1
+6
-1
@@ -154,7 +154,12 @@ func (d *Detector) AddGitleaksIgnore(gitleaksIgnorePath string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
defer file.Close()
|
// https://github.com/securego/gosec/issues/512
|
||||||
|
defer func() {
|
||||||
|
if err := file.Close(); err != nil {
|
||||||
|
log.Warn().Msgf("Error closing .gitleaksignore file: %s\n", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
scanner := bufio.NewScanner(file)
|
scanner := bufio.NewScanner(file)
|
||||||
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
|
|||||||
Reference in new issue
Block a user