From 8c06c4d6547a4f430e7ea987dcc811277ddb3e2d Mon Sep 17 00:00:00 2001 From: shawnps Date: Thu, 14 Jan 2016 03:29:26 -0800 Subject: [PATCH] move adding skipped dirs into GoTool fn --- check/go_vet.go | 3 +-- check/gocyclo.go | 3 +-- check/gofmt.go | 3 +-- check/golint.go | 3 +-- check/misspell.go | 3 +-- check/utils.go | 3 ++- 6 files changed, 7 insertions(+), 11 deletions(-) diff --git a/check/go_vet.go b/check/go_vet.go index 3932c0d..aee0eba 100644 --- a/check/go_vet.go +++ b/check/go_vet.go @@ -18,8 +18,7 @@ func (g GoVet) Weight() float64 { // Percentage returns the percentage of .go files that pass go vet func (g GoVet) Percentage() (float64, []FileSummary, error) { - params := AddSkipDirs([]string{"gometalinter", "--deadline=180s", "--disable-all", "--enable=vet"}) - return GoTool(g.Dir, g.Filenames, params) + return GoTool(g.Dir, g.Filenames, []string{"gometalinter", "--deadline=180s", "--disable-all", "--enable=vet"}) } // Description returns the description of go lint diff --git a/check/gocyclo.go b/check/gocyclo.go index 6eedbff..6027c23 100644 --- a/check/gocyclo.go +++ b/check/gocyclo.go @@ -18,8 +18,7 @@ func (g GoCyclo) Weight() float64 { // Percentage returns the percentage of .go files that pass gofmt func (g GoCyclo) Percentage() (float64, []FileSummary, error) { - params := AddSkipDirs([]string{"gometalinter", "--deadline=180s", "--disable-all", "--enable=gocyclo", "--cyclo-over=15"}) - return GoTool(g.Dir, g.Filenames, params) + return GoTool(g.Dir, g.Filenames, []string{"gometalinter", "--deadline=180s", "--disable-all", "--enable=gocyclo", "--cyclo-over=15"}) } // Description returns the description of GoCyclo diff --git a/check/gofmt.go b/check/gofmt.go index 7609ec4..3e55e21 100644 --- a/check/gofmt.go +++ b/check/gofmt.go @@ -18,8 +18,7 @@ func (g GoFmt) Weight() float64 { // Percentage returns the percentage of .go files that pass gofmt func (g GoFmt) Percentage() (float64, []FileSummary, error) { - params := AddSkipDirs([]string{"gometalinter", "--deadline=180s", "--disable-all", "--enable=gofmt"}) - return GoTool(g.Dir, g.Filenames, params) + return GoTool(g.Dir, g.Filenames, []string{"gometalinter", "--deadline=180s", "--disable-all", "--enable=gofmt"}) } // Description returns the description of gofmt diff --git a/check/golint.go b/check/golint.go index d0ad171..2c68676 100644 --- a/check/golint.go +++ b/check/golint.go @@ -18,8 +18,7 @@ func (g GoLint) Weight() float64 { // Percentage returns the percentage of .go files that pass golint func (g GoLint) Percentage() (float64, []FileSummary, error) { - params := AddSkipDirs([]string{"gometalinter", "--deadline=180s", "--disable-all", "--enable=golint"}) - return GoTool(g.Dir, g.Filenames, params) + return GoTool(g.Dir, g.Filenames, []string{"gometalinter", "--deadline=180s", "--disable-all", "--enable=golint"}) } // Description returns the description of go lint diff --git a/check/misspell.go b/check/misspell.go index aedd5bf..62df3c5 100644 --- a/check/misspell.go +++ b/check/misspell.go @@ -18,8 +18,7 @@ func (g Misspell) Weight() float64 { // Percentage returns the percentage of .go files that pass gofmt func (g Misspell) Percentage() (float64, []FileSummary, error) { - params := AddSkipDirs([]string{"gometalinter", "--deadline=180s", "--disable-all", "--linter", "misspell:misspell ./*.go:PATH:LINE:MESSAGE", "--enable=misspell"}) - return GoTool(g.Dir, g.Filenames, params) + return GoTool(g.Dir, g.Filenames, []string{"gometalinter", "--deadline=180s", "--disable-all", "--linter", "misspell:misspell ./*.go:PATH:LINE:MESSAGE", "--enable=misspell"}) } // Description returns the description of Misspell diff --git a/check/utils.go b/check/utils.go index 30cc060..1fb70d2 100644 --- a/check/utils.go +++ b/check/utils.go @@ -16,7 +16,7 @@ var ( skipSuffixes = []string{".pb.go", ".pb.gw.go"} ) -func AddSkipDirs(params []string) []string { +func addSkipDirs(params []string) []string { for _, dir := range skipDirs { params = append(params, fmt.Sprintf("--skip=%s", dir)) } @@ -117,6 +117,7 @@ func (fs *FileSummary) AddError(out string) error { // on a directory func GoTool(dir string, filenames, command []string) (float64, []FileSummary, error) { params := command[1:] + params = addSkipDirs(params) params = append(params, dir+"/...") cmd := exec.Command(command[0], params...)