fix some lint issues
This commit is contained in:
parent
fddfe4523e
commit
d39b988da1
@ -53,7 +53,11 @@ func (c Config) Update() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// restore branch
|
// 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 {
|
for _, branch := range branches {
|
||||||
branch = strings.TrimSpace(branch)
|
branch = strings.TrimSpace(branch)
|
||||||
|
@ -24,17 +24,17 @@ type MockGitConfig struct {
|
|||||||
mock.Mock
|
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)
|
args := mgc.Called(a, b)
|
||||||
return args.Get(0).(map[string]struct{}), args.Error(1)
|
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)
|
args := mgc.Called(a)
|
||||||
return args.Get(0).([]string), args.Error(1)
|
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)
|
args := mgc.Called(a, b)
|
||||||
return args.Error(0)
|
return args.Error(0)
|
||||||
}
|
}
|
||||||
|
4
debian/debian.go
vendored
4
debian/debian.go
vendored
@ -31,7 +31,9 @@ func Update() error {
|
|||||||
for pkgName, cves := range vulns {
|
for pkgName, cves := range vulns {
|
||||||
for cveID, cve := range cves {
|
for cveID, cve := range cves {
|
||||||
dir := filepath.Join(utils.VulnListDir(), debianDir, pkgName)
|
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))
|
filePath := filepath.Join(dir, fmt.Sprintf("%s.json", cveID))
|
||||||
if err = utils.Write(filePath, cve); err != nil {
|
if err = utils.Write(filePath, cve); err != nil {
|
||||||
return xerrors.Errorf("failed to write Debian CVE details: %w", err)
|
return xerrors.Errorf("failed to write Debian CVE details: %w", err)
|
||||||
|
@ -70,6 +70,9 @@ func Update() error {
|
|||||||
|
|
||||||
func walkDir(root string) error {
|
func walkDir(root string) error {
|
||||||
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) 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() {
|
if info.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -152,15 +152,13 @@ func FetchConcurrently(urls []string, concurrency, wait, retry int) (responses [
|
|||||||
tasks := GenWorkers(concurrency, wait)
|
tasks := GenWorkers(concurrency, wait)
|
||||||
for range urls {
|
for range urls {
|
||||||
tasks <- func() {
|
tasks <- func() {
|
||||||
select {
|
url := <-reqChan
|
||||||
case url := <-reqChan:
|
res, err := FetchURL(url, "", retry)
|
||||||
res, err := FetchURL(url, "", retry)
|
if err != nil {
|
||||||
if err != nil {
|
errChan <- err
|
||||||
errChan <- err
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
resChan <- res
|
|
||||||
}
|
}
|
||||||
|
resChan <- res
|
||||||
}
|
}
|
||||||
bar.Increment()
|
bar.Increment()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user