MCPcopy Create free account
hub / github.com/driangle/taskmd / checkPhaseConfig

Method checkPhaseConfig

sdk/go/validator/validator.go:416–457  ·  view source on GitHub ↗

checkPhaseConfig validates phase entries for structural issues and duplicates.

(config *ConfigData, result *ValidationResult)

Source from the content-addressed store, hash-verified

414
415// checkPhaseConfig validates phase entries for structural issues and duplicates.
416func (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.
460func (v *Validator) checkConfigScopes(config *ConfigData, result *ValidationResult) {

Callers 1

ValidateConfigMethod · 0.95

Calls 1

AddIssueMethod · 0.80

Tested by

no test coverage detected