Skip to content

Commit 8ab9fe9

Browse files
committed
some more minor changes
Signed-off-by: Callum Styan <[email protected]>
1 parent 4fc0a54 commit 8ab9fe9

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

cmd/readmevalidation/contributors.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,13 @@ func aggregateContributorReadmeFiles() ([]readme, error) {
239239

240240
allReadmeFiles := []readme{}
241241
errs := []error{}
242+
dirPath := ""
242243
for _, e := range dirEntries {
243244
if !e.IsDir() {
244245
continue
245246
}
246247

247-
dirPath := path.Join(rootRegistryPath, e.Name())
248+
dirPath = path.Join(rootRegistryPath, e.Name())
248249

249250
readmePath := path.Join(dirPath, "README.md")
250251
rmBytes, err := os.ReadFile(readmePath)
@@ -268,7 +269,7 @@ func aggregateContributorReadmeFiles() ([]readme, error) {
268269
return allReadmeFiles, nil
269270
}
270271

271-
func validateContributorRelativeUrls(contributors map[string]contributorProfileReadme) error {
272+
func validateContributorRelativeURLs(contributors map[string]contributorProfileReadme) error {
272273
// This function only validates relative avatar URLs for now, but it can be beefed up to validate more in the future.
273274
errs := []error{}
274275

@@ -317,7 +318,7 @@ func validateAllContributorFiles() error {
317318
}
318319
logger.Info(context.Background(), "Processed README files as valid contributor profiles", "num_contributors", len(contributors))
319320

320-
if err = validateContributorRelativeUrls(contributors); err != nil {
321+
if err = validateContributorRelativeURLs(contributors); err != nil {
321322
return err
322323
}
323324
logger.Info(context.Background(), "All relative URLs for READMEs are valid")

cmd/readmevalidation/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ func main() {
2020

2121
// If there are fundamental problems with how the repo is structured, we can't make any guarantees that any further
2222
// validations will be relevant or accurate.
23-
repoErr := validateRepoStructure()
24-
if repoErr != nil {
25-
logger.Error(context.Background(), repoErr.Error())
23+
err := validateRepoStructure()
24+
if err != nil {
25+
logger.Error(context.Background(), "Error when validating the repo structure", "error", err.Error())
2626
os.Exit(1)
2727
}
2828

2929
var errs []error
30-
err := validateAllContributorFiles()
30+
err = validateAllContributorFiles()
3131
if err != nil {
3232
errs = append(errs, err)
3333
}

cmd/readmevalidation/readmefiles.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ func validateReadmeBody(body string) []error {
132132
continue
133133
}
134134

135-
if spaceAfterHeader := headerGroups[2]; spaceAfterHeader == "" {
135+
// In the Markdown spec it is mandatory to have a space following the header # symbol(s).
136+
if headerGroups[2] == "" {
136137
errs = append(errs, errors.New("header does not have space between header characters and main header text"))
137138
}
138139

0 commit comments

Comments
 (0)