mirror of
https://github.com/gojp/goreportcard.git
synced 2026-01-29 06:49:05 +08:00
return custom error response when no .go files are found in the repo, add missing return after 500 error
This commit is contained in:
@@ -20,6 +20,7 @@ func CheckHandler(w http.ResponseWriter, r *http.Request) {
|
||||
b, _ := json.Marshal(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write(b)
|
||||
return
|
||||
}
|
||||
|
||||
b, err := json.Marshal(resp)
|
||||
|
||||
@@ -121,6 +121,9 @@ func newChecksResp(repo string, forceRefresh bool) (checksResp, error) {
|
||||
if err != nil {
|
||||
return checksResp{}, fmt.Errorf("Could not get filenames: %v", err)
|
||||
}
|
||||
if len(filenames) == 0 {
|
||||
return checksResp{}, fmt.Errorf("No .go files found")
|
||||
}
|
||||
checks := []check.Check{check.GoFmt{Dir: dir, Filenames: filenames},
|
||||
check.GoVet{Dir: dir, Filenames: filenames},
|
||||
check.GoLint{Dir: dir, Filenames: filenames},
|
||||
|
||||
Reference in New Issue
Block a user