diff --git a/check/go_vet.go b/check/go_vet.go index aee0eba..4f332d0 100644 --- a/check/go_vet.go +++ b/check/go_vet.go @@ -13,7 +13,7 @@ func (g GoVet) Name() string { // Weight returns the weight this check has in the overall average func (g GoVet) Weight() float64 { - return .35 + return .25 } // Percentage returns the percentage of .go files that pass go vet diff --git a/check/gocyclo.go b/check/gocyclo.go index 17c0e59..6027c23 100644 --- a/check/gocyclo.go +++ b/check/gocyclo.go @@ -13,7 +13,7 @@ func (g GoCyclo) Name() string { // Weight returns the weight this check has in the overall average func (g GoCyclo) Weight() float64 { - return .05 + return .10 } // Percentage returns the percentage of .go files that pass gofmt diff --git a/check/gofmt.go b/check/gofmt.go index 3962c73..ebe501f 100644 --- a/check/gofmt.go +++ b/check/gofmt.go @@ -13,7 +13,7 @@ func (g GoFmt) Name() string { // Weight returns the weight this check has in the overall average func (g GoFmt) Weight() float64 { - return .40 + return .30 } // Percentage returns the percentage of .go files that pass gofmt diff --git a/check/ineffassign.go b/check/ineffassign.go index 945c093..61cb924 100644 --- a/check/ineffassign.go +++ b/check/ineffassign.go @@ -13,7 +13,7 @@ func (g IneffAssign) Name() string { // Weight returns the weight this check has in the overall average func (g IneffAssign) Weight() float64 { - return 0.0 + return 0.05 } // Percentage returns the percentage of .go files that pass gofmt diff --git a/check/license.go b/check/license.go index 30b4744..4cf3793 100644 --- a/check/license.go +++ b/check/license.go @@ -19,7 +19,7 @@ func (g License) Name() string { // Weight returns the weight this check has in the overall average func (g License) Weight() float64 { - return .10 + return .05 } // thank you https://github.com/ryanuber/go-license and client9 diff --git a/handlers/checks.go b/handlers/checks.go index df80136..e2d73b7 100644 --- a/handlers/checks.go +++ b/handlers/checks.go @@ -15,7 +15,7 @@ import ( "time" "github.com/boltdb/bolt" - "github.com/dustin/go-humanize" + humanize "github.com/dustin/go-humanize" "github.com/gojp/goreportcard/check" ) @@ -185,6 +185,7 @@ func newChecksResp(repo string, forceRefresh bool) (checksResp, error) { check.License{Dir: dir, Filenames: []string{}}, check.Misspell{Dir: dir, Filenames: filenames}, check.IneffAssign{Dir: dir, Filenames: filenames}, + check.ErrCheck{Dir: dir, Filenames: filenames}, } ch := make(chan score) @@ -213,17 +214,20 @@ func newChecksResp(repo string, forceRefresh bool) (checksResp, error) { } var total float64 + var totalWeight float64 var issues = make(map[string]bool) for i := 0; i < len(checks); i++ { s := <-ch resp.Checks = append(resp.Checks, s) total += s.Percentage * s.Weight + totalWeight += s.Weight for _, fs := range s.FileSummaries { issues[fs.Filename] = true } } + total /= totalWeight - sort.Sort(ByName(resp.Checks)) + sort.Sort(ByWeight(resp.Checks)) resp.Average = total resp.Issues = len(issues) resp.Grade = grade(total * 100) @@ -231,9 +235,9 @@ func newChecksResp(repo string, forceRefresh bool) (checksResp, error) { return resp, nil } -// ByName implements sorting for checks alphabetically by name -type ByName []score +// ByWeight implements sorting for checks by weight descending +type ByWeight []score -func (a ByName) Len() int { return len(a) } -func (a ByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a ByName) Less(i, j int) bool { return a[i].Name < a[j].Name } +func (a ByWeight) Len() int { return len(a) } +func (a ByWeight) Swap(i, j int) { a[i], a[j] = a[j], a[i] } +func (a ByWeight) Less(i, j int) bool { return a[i].Weight > a[j].Weight }