Skip to content

Commit db2fd0e

Browse files
committed
fix: update README validation to block empty strings
1 parent ba06233 commit db2fd0e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

cmd/readmevalidation/readmeFiles.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,19 @@ var readmeHeaderRe = regexp.MustCompile("^(#{1,})(\\s*)")
7272
// this is by parsing this as an AST, and then checking the resulting nodes
7373
func validateReadmeBody(body string) []error {
7474
trimmed := strings.TrimSpace(body)
75-
var errs []error
75+
76+
if trimmed == "" {
77+
return []error{errors.New("README body is empty")}
78+
}
7679

7780
// If the very first line of the README, there's a risk that the rest of the
7881
// validation logic will break, since we don't have many guarantees about
7982
// how the README is actually structured
8083
if !strings.HasPrefix(trimmed, "# ") {
81-
errs = append(errs, errors.New("README body must start with ATX-style h1 header (i.e., \"# \")"))
82-
return errs
84+
return []error{errors.New("README body must start with ATX-style h1 header (i.e., \"# \")")}
8385
}
8486

87+
var errs []error
8588
latestHeaderLevel := 0
8689
foundFirstH1 := false
8790
isInCodeBlock := false

0 commit comments

Comments
 (0)