MCPcopy
hub / github.com/larksuite/cli / LegacyCommandErrorCandidatesForRepo

Function LegacyCommandErrorCandidatesForRepo

lint/errscontract/scan.go:178–210  ·  view source on GitHub ↗
(root string)

Source from the content-addressed store, hash-verified

176}
177
178func LegacyCommandErrorCandidatesForRepo(root string) ([]string, error) {
179 var out []string
180 walkErr := filepath.WalkDir(root, func(path string, d fs.DirEntry, walkErr error) error {
181 if walkErr != nil {
182 return walkErr
183 }
184 if d.IsDir() {
185 if skipLintDir(d.Name()) {
186 return filepath.SkipDir
187 }
188 return nil
189 }
190 if !strings.HasSuffix(path, ".go") || strings.HasSuffix(path, "_test.go") {
191 return nil
192 }
193 rel, _ := filepath.Rel(root, path)
194 rel = filepath.ToSlash(rel)
195 if !isCommandBoundaryScope(rel) {
196 return nil
197 }
198 src, err := os.ReadFile(path) //nolint:gosec // repo root is operator-provided.
199 if err != nil {
200 return fmt.Errorf("read %s: %w", path, err)
201 }
202 out = append(out, LegacyCommandErrorCandidates(rel, string(src))...)
203 return nil
204 })
205 if walkErr != nil {
206 return nil, walkErr
207 }
208 sort.Strings(out)
209 return out, nil
210}
211
212func skipLintDir(name string) bool {
213 return name == ".git" || name == "node_modules" || name == "vendor" ||

Callers 1

mainFunction · 0.92

Calls 6

skipLintDirFunction · 0.85
isCommandBoundaryScopeFunction · 0.85
IsDirMethod · 0.65
NameMethod · 0.65
ReadFileMethod · 0.65

Tested by

no test coverage detected