checkPhaseConfig validates phase entries for structural issues and duplicates.
(config *ConfigData, result *ValidationResult)
| 414 | |
| 415 | // checkPhaseConfig validates phase entries for structural issues and duplicates. |
| 416 | func (v *Validator) checkPhaseConfig(config *ConfigData, result *ValidationResult) { |
| 417 | if len(config.Phases) == 0 { |
| 418 | return |
| 419 | } |
| 420 | |
| 421 | seenIDs := make(map[string]bool) |
| 422 | seenNames := make(map[string]bool) |
| 423 | |
| 424 | for i, phase := range config.Phases { |
| 425 | // Structural checks |
| 426 | if phase.Name == "" { |
| 427 | result.AddIssue(LevelError, "", config.ConfigPath, |
| 428 | fmt.Sprintf("phase at index %d is missing required field: name", i)) |
| 429 | } |
| 430 | |
| 431 | if phase.ID == "" { |
| 432 | label := phase.Name |
| 433 | if label == "" { |
| 434 | label = fmt.Sprintf("index %d", i) |
| 435 | } |
| 436 | result.AddIssue(LevelWarning, "", config.ConfigPath, |
| 437 | fmt.Sprintf("phase '%s' is missing field: id (falling back to name)", label)) |
| 438 | } |
| 439 | |
| 440 | // Duplicate checks |
| 441 | if phase.ID != "" { |
| 442 | if seenIDs[phase.ID] { |
| 443 | result.AddIssue(LevelWarning, "", config.ConfigPath, |
| 444 | fmt.Sprintf("duplicate phase id: '%s'", phase.ID)) |
| 445 | } |
| 446 | seenIDs[phase.ID] = true |
| 447 | } |
| 448 | |
| 449 | if phase.Name != "" { |
| 450 | if seenNames[phase.Name] { |
| 451 | result.AddIssue(LevelWarning, "", config.ConfigPath, |
| 452 | fmt.Sprintf("duplicate phase name: '%s'", phase.Name)) |
| 453 | } |
| 454 | seenNames[phase.Name] = true |
| 455 | } |
| 456 | } |
| 457 | } |
| 458 | |
| 459 | // checkConfigScopes validates each scope entry has a non-empty paths array. |
| 460 | func (v *Validator) checkConfigScopes(config *ConfigData, result *ValidationResult) { |
no test coverage detected