diff --git a/tools/cmd/linter/main.go b/tools/cmd/linter/main.go index 76294803..06fa7e24 100644 --- a/tools/cmd/linter/main.go +++ b/tools/cmd/linter/main.go @@ -556,9 +556,11 @@ func getFeatureMaturityLevel(category string) ([]maturityLevel, error) { // the third row is the status scanner.Scan() ss := strings.Split(scanner.Text(), "|") - if len(ss) > 2 { - status = strings.ToLower(strings.TrimSpace(ss[2])) + if len(ss) < 3 { + return fmt.Errorf("status is missing in the `## Attribute` table of %s", path) } + + status = strings.ToLower(strings.TrimSpace(ss[2])) break } } @@ -614,22 +616,32 @@ func lintFeatureMaturityLevel() error { for category, recs := range records { for _, record := range recs { - if record.Status == "experimental" && record.ExperimentalSince == "" { - return fmt.Errorf("experimental_since of %s %s is missing in %s", category, record.Name, recordFile) + if record.Status == "experimental" { + if record.ExperimentalSince == "" { + return fmt.Errorf("experimental_since of %s %s is missing in %s", category, record.Name, recordFile) + } + } else if record.Status == "stable" { + if record.StableSince == "" { + return fmt.Errorf("stable_since of %s %s is missing in %s", category, record.Name, recordFile) + } + } else { + return fmt.Errorf("status '%s' of %s %s is invalid in %s", record.Status, category, record.Name, recordFile) } + found := false for i, r := range actualRecords[category] { if r.Name == record.Name { found = true if r.Status != record.Status { - return fmt.Errorf("status of %s %s is mismatched between %s and the documentation", category, record.Name, recordFile) + return fmt.Errorf("status of %s %s is mismatched between %s and the documentation. Please update the record in %s.", + category, record.Name, recordFile, recordFile) } actualRecords[category] = slices.Delete(actualRecords[category], i, i+1) break } } if !found { - return fmt.Errorf("%s %s is missing in the documentation", category, record.Name) + return fmt.Errorf("feature maturity record of %s %s is missing in the documentation", category, record.Name) } } } diff --git a/types/plugins/plugins_test.go b/types/plugins/plugins_test.go index 1e45b915..19ab05b2 100644 --- a/types/plugins/plugins_test.go +++ b/types/plugins/plugins_test.go @@ -40,7 +40,11 @@ func snakeToCamel(s string) string { } func getSecondColumn(line string) string { - return strings.TrimSpace(strings.Split(line, "|")[2]) + cols := strings.Split(line, "|") + if len(cols) < 3 { + return "" + } + return strings.TrimSpace(cols[2]) } func TestCheckPluginAttributes(t *testing.T) {