mirror of
https://github.com/gojp/goreportcard.git
synced 2026-01-29 06:49:05 +08:00
move adding skipped dirs into GoTool fn
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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...)
|
||||
|
||||
Reference in New Issue
Block a user