move adding skipped dirs into GoTool fn

This commit is contained in:
shawnps
2016-01-14 03:29:26 -08:00
parent a823cf0afa
commit 8c06c4d654
6 changed files with 7 additions and 11 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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...)