(root string)
| 176 | } |
| 177 | |
| 178 | func 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 | |
| 212 | func skipLintDir(name string) bool { |
| 213 | return name == ".git" || name == "node_modules" || name == "vendor" || |
no test coverage detected