#40 start license check

This commit is contained in:
Shawn Smith
2015-10-14 12:08:38 +09:00
parent bf0f6330fd
commit feeccfa3db
2 changed files with 39 additions and 0 deletions

38
check/license.go Normal file
View File

@@ -0,0 +1,38 @@
package check
import (
"bytes"
"os/exec"
)
// License is the check for the go cyclo command
type License struct {
Dir string
Filenames []string
}
// Name returns the name of the display name of the command
func (g License) Name() string {
return "license"
}
// Percentage returns 0 if no LICENSE, 100 if LICENSE
func (g License) Percentage() (float64, []FileSummary, error) {
cmd := exec.Command("find", g.Dir, "-maxdepth", "1", "-type", "f", "-name", "LICENSE")
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
if err != nil {
return 0.0, []FileSummary{}, err
}
if out.String() == "" {
return 0.0, []FileSummary{}, nil
}
return 100.0, []FileSummary{}, nil
}
// Description returns the description of License
func (g License) Description() string {
return "Checks whether your project has a LICENSE file."
}

View File

@@ -132,6 +132,7 @@ func newChecksResp(repo string, forceRefresh bool) (checksResp, error) {
check.GoVet{Dir: dir, Filenames: filenames},
check.GoLint{Dir: dir, Filenames: filenames},
check.GoCyclo{Dir: dir, Filenames: filenames},
check.License{Dir: dir, Filenames: []string{}},
}
ch := make(chan score)