Skip to content

Commit f23bbca

Browse files
committed
refactor: start making main() leaner
1 parent 19226af commit f23bbca

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

cmd/readmevalidation/contributors.go

+23
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"errors"
55
"fmt"
6+
"log"
67
"net/url"
78
"os"
89
"path"
@@ -371,3 +372,25 @@ func validateContributorRelativeUrls(contributors map[string]contributorProfile)
371372
errors: problems,
372373
}
373374
}
375+
376+
func validateAllContributors(errChan chan<- error) {
377+
allReadmeFiles, err := aggregateContributorReadmeFiles()
378+
if err != nil {
379+
errChan <- err
380+
return
381+
}
382+
log.Printf("Processing %d README files\n", len(allReadmeFiles))
383+
contributors, err := parseContributorFiles(allReadmeFiles)
384+
log.Printf("Processed %d README files as valid contributor profiles", len(contributors))
385+
if err != nil {
386+
errChan <- err
387+
return
388+
}
389+
err = validateContributorRelativeUrls(contributors)
390+
if err != nil {
391+
errChan <- err
392+
return
393+
}
394+
log.Println("All relative URLs for READMEs are valid")
395+
log.Printf("Processed all READMEs in the %q directory\n", rootRegistryPath)
396+
}

cmd/readmevalidation/main.go

+1-20
Original file line numberDiff line numberDiff line change
@@ -87,26 +87,7 @@ func main() {
8787
wg.Add(1)
8888
go func() {
8989
defer wg.Done()
90-
91-
allReadmeFiles, err := aggregateContributorReadmeFiles()
92-
if err != nil {
93-
errChan <- err
94-
return
95-
}
96-
log.Printf("Processing %d README files\n", len(allReadmeFiles))
97-
contributors, err := parseContributorFiles(allReadmeFiles)
98-
log.Printf("Processed %d README files as valid contributor profiles", len(contributors))
99-
if err != nil {
100-
errChan <- err
101-
return
102-
}
103-
err = validateContributorRelativeUrls(contributors)
104-
if err != nil {
105-
errChan <- err
106-
return
107-
}
108-
log.Println("All relative URLs for READMEs are valid")
109-
log.Printf("Processed all READMEs in the %q directory\n", rootRegistryPath)
90+
validateAllContributors(errChan)
11091
}()
11192

11293
// Validate modules

0 commit comments

Comments
 (0)