Skip to content

Commit dc88fb1

Browse files
committed
remove redundant error check
1 parent b9eab46 commit dc88fb1

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

Diff for: scan.go

+25-28
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,31 @@ import (
66
"strings"
77
)
88

9+
func scanGitFolders(root string) ([]string, error) {
10+
var gitFolders []string
11+
err := filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error {
12+
if err != nil {
13+
return err
14+
}
15+
16+
if d.IsDir() && d.Name() == ".git" {
17+
gitFolder := filepath.Dir(path)
18+
gitFolders = append(gitFolders, gitFolder)
19+
return filepath.SkipDir // Skip further traversal within this directory
20+
}
21+
22+
// Skip dependency directories
23+
_, ok := excludedFolders[strings.ToLower(d.Name())]
24+
if d.IsDir() && ok {
25+
return filepath.SkipDir
26+
}
27+
28+
return nil
29+
})
30+
31+
return gitFolders, err
32+
}
33+
934
// excludedFolders is a map of folder names (case-insensitive) to be excluded during the scan.
1035
var excludedFolders = map[string]struct{}{
1136
"node_modules": {},
@@ -40,31 +65,3 @@ var excludedFolders = map[string]struct{}{
4065
".vagrant": {},
4166
".serverless": {},
4267
}
43-
44-
func scanGitFolders(root string) ([]string, error) {
45-
var gitFolders []string
46-
err := filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error {
47-
if err != nil {
48-
return err
49-
}
50-
51-
if d.IsDir() && d.Name() == ".git" {
52-
gitFolder := filepath.Dir(path)
53-
gitFolders = append(gitFolders, gitFolder)
54-
return filepath.SkipDir // Skip further traversal within this directory
55-
}
56-
57-
// Skip dependency directories
58-
_, ok := excludedFolders[strings.ToLower(d.Name())]
59-
if d.IsDir() && ok {
60-
return filepath.SkipDir
61-
}
62-
63-
return nil
64-
})
65-
66-
if err != nil {
67-
return nil, err
68-
}
69-
return gitFolders, nil
70-
}

0 commit comments

Comments
 (0)