fix some lint issues

This commit is contained in:
knqyf263 2019-10-12 09:54:08 +03:00
parent fddfe4523e
commit d39b988da1
5 changed files with 20 additions and 13 deletions

View File

@ -53,7 +53,11 @@ func (c Config) Update() (err error) {
}
// restore branch
defer c.GitClient.Checkout(repoDir, "master")
defer func() {
if derr := c.GitClient.Checkout(repoDir, "master"); derr != nil {
log.Printf("checkout error: %s", derr)
}
}()
for _, branch := range branches {
branch = strings.TrimSpace(branch)

View File

@ -24,17 +24,17 @@ type MockGitConfig struct {
mock.Mock
}
func (mgc MockGitConfig) CloneOrPull(a string, b string) (map[string]struct{}, error) {
func (mgc *MockGitConfig) CloneOrPull(a string, b string) (map[string]struct{}, error) {
args := mgc.Called(a, b)
return args.Get(0).(map[string]struct{}), args.Error(1)
}
func (mgc MockGitConfig) RemoteBranch(a string) ([]string, error) {
func (mgc *MockGitConfig) RemoteBranch(a string) ([]string, error) {
args := mgc.Called(a)
return args.Get(0).([]string), args.Error(1)
}
func (mgc MockGitConfig) Checkout(a string, b string) error {
func (mgc *MockGitConfig) Checkout(a string, b string) error {
args := mgc.Called(a, b)
return args.Error(0)
}

4
debian/debian.go vendored
View File

@ -31,7 +31,9 @@ func Update() error {
for pkgName, cves := range vulns {
for cveID, cve := range cves {
dir := filepath.Join(utils.VulnListDir(), debianDir, pkgName)
os.MkdirAll(dir, os.ModePerm)
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
return xerrors.Errorf("failed to create the directory: %w", err)
}
filePath := filepath.Join(dir, fmt.Sprintf("%s.json", cveID))
if err = utils.Write(filePath, cve); err != nil {
return xerrors.Errorf("failed to write Debian CVE details: %w", err)

View File

@ -70,6 +70,9 @@ func Update() error {
func walkDir(root string) error {
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
if err != nil {
return xerrors.Errorf("file walk error: %w", err)
}
if info.IsDir() {
return nil
}

View File

@ -152,15 +152,13 @@ func FetchConcurrently(urls []string, concurrency, wait, retry int) (responses [
tasks := GenWorkers(concurrency, wait)
for range urls {
tasks <- func() {
select {
case url := <-reqChan:
res, err := FetchURL(url, "", retry)
if err != nil {
errChan <- err
return
}
resChan <- res
url := <-reqChan
res, err := FetchURL(url, "", retry)
if err != nil {
errChan <- err
return
}
resChan <- res
}
bar.Increment()
}