feat: warnings en indexer para file_path inexistentes en disco

Valida post-insert que file_path y test_file_path de funciones y tipos apunten a archivos reales. Reporta warnings sin bloquear el indexado.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-03 03:23:25 +02:00
parent 87e8f33b01
commit 619a56c567
2 changed files with 28 additions and 0 deletions
+3
View File
@@ -127,6 +127,9 @@ func cmdIndex() {
for _, e := range result.ValidationErrors {
fmt.Fprintf(os.Stderr, " INVALID: %s\n", e)
}
for _, w := range result.Warnings {
fmt.Fprintf(os.Stderr, " WARN: %s\n", w)
}
for _, e := range result.Errors {
fmt.Fprintf(os.Stderr, " ERROR: %s\n", e)
}
+25
View File
@@ -15,6 +15,7 @@ type IndexResult struct {
Apps int
Analysis int
ValidationErrors []string
Warnings []string
Errors []string
}
@@ -202,6 +203,30 @@ func Index(db *DB, root string) (*IndexResult, error) {
result.Analysis++
}
// Post-insert: warn about file_path entries that don't exist on disk
for _, f := range functions {
if f.FilePath != "" {
abs := filepath.Join(root, f.FilePath)
if _, err := os.Stat(abs); err != nil {
result.Warnings = append(result.Warnings, fmt.Sprintf("%s: file_path %q not found", f.ID, f.FilePath))
}
}
if f.TestFilePath != "" {
abs := filepath.Join(root, f.TestFilePath)
if _, err := os.Stat(abs); err != nil {
result.Warnings = append(result.Warnings, fmt.Sprintf("%s: test_file_path %q not found", f.ID, f.TestFilePath))
}
}
}
for _, t := range types {
if t.FilePath != "" {
abs := filepath.Join(root, t.FilePath)
if _, err := os.Stat(abs); err != nil {
result.Warnings = append(result.Warnings, fmt.Sprintf("%s: file_path %q not found", t.ID, t.FilePath))
}
}
}
return result, nil
}