Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing megacheck issues reported by gometalinter #236

Merged
merged 1 commit into from Jun 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions download/download.go
Expand Up @@ -84,6 +84,9 @@ func download(path, dest string, firstAttempt bool) (root *vcs.RepoRoot, err err
// may have been rebased; we delete the directory, then try one more time:
log.Printf("Failed to update %q (%v), trying again...", root.Repo, err.Error())
err = os.RemoveAll(fullLocalPath)
if err != nil {
log.Printf("Failed to delete directory %s", fullLocalPath)
}
return download(path, dest, false)
}
return root, err
Expand Down
1 change: 0 additions & 1 deletion handlers/about.go
Expand Up @@ -11,5 +11,4 @@ func AboutHandler(w http.ResponseWriter, r *http.Request) {
t.Execute(w, map[string]interface{}{
"google_analytics_key": googleAnalyticsKey,
})
return
}
5 changes: 2 additions & 3 deletions handlers/badge.go
Expand Up @@ -49,8 +49,7 @@ func badgePath(grade Grade, style string, dev bool) string {

// BadgeHandler handles fetching the badge images
func BadgeHandler(w http.ResponseWriter, r *http.Request, repo string, dev bool) {
name := fmt.Sprintf("%s", repo)
resp, err := newChecksResp(name, false)
resp, err := newChecksResp(repo, false)

// See: http://shields.io/#styles
style := r.URL.Query().Get("style")
Expand All @@ -59,7 +58,7 @@ func BadgeHandler(w http.ResponseWriter, r *http.Request, repo string, dev bool)
}

if err != nil {
log.Printf("ERROR: fetching badge for %s: %v", name, err)
log.Printf("ERROR: fetching badge for %s: %v", repo, err)
url := "https://img.shields.io/badge/go%20report-error-lightgrey.svg?style=" + style
http.Redirect(w, r, url, http.StatusTemporaryRedirect)
return
Expand Down
15 changes: 2 additions & 13 deletions handlers/check.go
Expand Up @@ -51,7 +51,6 @@ func CheckHandler(w http.ResponseWriter, r *http.Request) {
}
w.WriteHeader(http.StatusOK)
w.Write(b)
return
}

func updateHighScores(mb *bolt.Bucket, resp checksResp, repo string) error {
Expand Down Expand Up @@ -96,12 +95,7 @@ func updateHighScores(mb *bolt.Bucket, resp checksResp, repo string) error {
if err != nil {
return err
}
err = mb.Put([]byte("scores"), scoreBytes)
if err != nil {
return err
}

return nil
return mb.Put([]byte("scores"), scoreBytes)
}

func updateReposCount(mb *bolt.Bucket, repo string) (err error) {
Expand Down Expand Up @@ -155,12 +149,7 @@ func updateRecentlyViewed(mb *bolt.Bucket, repo string) error {
if err != nil {
return err
}
err = mb.Put([]byte("recent"), b)
if err != nil {
return err
}

return nil
return mb.Put([]byte("recent"), b)
}

//func updateMetadata(tx *bolt.Tx, resp checksResp, repo string, isNewRepo bool, oldScore *float64) error {
Expand Down
2 changes: 1 addition & 1 deletion tools/clean-repos/main.go
Expand Up @@ -26,7 +26,7 @@ func main() {
}
for _, d := range dirs {
path := "_repos/src/" + f.Name() + "/" + d.Name()
if time.Now().Sub(d.ModTime()) > 30*24*time.Hour {
if time.Since(d.ModTime()) > 30*24*time.Hour {
if *real {
log.Printf("Deleting %s (repo is old)...", path)
os.RemoveAll(path)
Expand Down
9 changes: 2 additions & 7 deletions tools/db/manage_db.go
Expand Up @@ -56,12 +56,7 @@ func deleteRepo(repo string) error {
return err
}

err = mb.Put([]byte("scores"), scoreBytes)
if err != nil {
return err
}

return nil
return mb.Put([]byte("scores"), scoreBytes)
})

}
Expand Down Expand Up @@ -110,7 +105,7 @@ func listDuplicates() error {

func main() {
flag.Parse()
if *repo == "" && *listDupes == false {
if *repo == "" && !*listDupes {
log.Println("Usage: manage_db.go [-list-duplicates] [-remove repo]")
return
}
Expand Down
7 changes: 1 addition & 6 deletions tools/names/migrate_repo_names.go
Expand Up @@ -75,12 +75,7 @@ func main() {
if err != nil {
return err
}
err = mb.Put([]byte("scores"), scoreBytes)
if err != nil {
return err
}

return nil
return mb.Put([]byte("scores"), scoreBytes)
})
if err != nil {
log.Fatal(err)
Expand Down
5 changes: 1 addition & 4 deletions tools/scores/init_repo_scores.go
Expand Up @@ -10,10 +10,7 @@ import (
"github.com/gojp/goreportcard/handlers"
)

const (
repoBucket string = "repos"
metaBucket string = "meta"
)
const repoBucket = "repos"

type checksResp struct {
Repo string `json:"repo"`
Expand Down