(schemaCompiler *jsonschema.Compiler, results *schemaLintResults, vectorDir string)
| 197 | } |
| 198 | |
| 199 | func lintVectorDir(schemaCompiler *jsonschema.Compiler, results *schemaLintResults, vectorDir string) error { |
| 200 | err := filepath.WalkDir(vectorDir, func(path string, d fs.DirEntry, err error) error { |
| 201 | if err != nil { |
| 202 | return err |
| 203 | } |
| 204 | |
| 205 | if d.IsDir() || !strings.HasSuffix(d.Name(), ".json") { |
| 206 | return nil |
| 207 | } |
| 208 | |
| 209 | if vectorRegex != nil && !vectorRegex.MatchString(d.Name()) { |
| 210 | return nil |
| 211 | } |
| 212 | |
| 213 | results.total++ |
| 214 | |
| 215 | vectorData, err := os.ReadFile(path) |
| 216 | if err != nil { |
| 217 | return fmt.Errorf("failed to read %s: %w", path, err) |
| 218 | } |
| 219 | |
| 220 | if err := lintVectorTestGroups(vectorData, path); err != nil { |
| 221 | log.Printf("❌ %q: %s\n", path, err) |
| 222 | results.invalid++ |
| 223 | return nil |
| 224 | } |
| 225 | |
| 226 | if err := lintVectorToSchema(schemaCompiler, vectorData, path, results); err != nil { |
| 227 | return err |
| 228 | } |
| 229 | |
| 230 | return nil |
| 231 | }) |
| 232 | if err != nil { |
| 233 | return fmt.Errorf("error walking directory: %w", err) |
| 234 | } |
| 235 | |
| 236 | return nil |
| 237 | } |
| 238 | |
| 239 | func lintVectorTestGroups(vectorData []byte, path string) error { |
| 240 | var vector struct { |
no test coverage detected