Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Commit

Permalink
golint: fix issues
Browse files Browse the repository at this point in the history
Signed-off-by: mcoops <[email protected]>
  • Loading branch information
mcoops committed Aug 26, 2021
1 parent c6391df commit a19191f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
13 changes: 3 additions & 10 deletions internal/scan/golang.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"time"

"golang.org/x/mod/semver"
"golang.org/x/tools/go/packages"
)

type GoListDeps struct {
Expand All @@ -31,12 +30,6 @@ type GoPkg struct {
Gofiles []string
}

const defaultOptions = packages.NeedDeps |
packages.NeedImports |
packages.NeedModule |
packages.NeedFiles |
packages.NeedName

func getVersion(deps GoListDeps) string {
/* if replace is specified, then use that version
* not seen when version and replace.version are differnt
Expand All @@ -57,13 +50,13 @@ func runCmd(path string, mod bool) ([]byte, error) {
// go list -f '{{if not .Standard}}{{.Module}}{{end}}' -json -deps ./...
var cmd *exec.Cmd

if mod == false {
if !mod {
cmd = exec.CommandContext(ctx, "go", "list", "-f", "'{{if not .Standard}}{{.Module}}{{end}}'", "-json", "-deps", "./...")
} else {
vendorDir := filepath.Join(filepath.Dir(path), "vendor")
if _, err := os.Stat(vendorDir); err != nil {
if os.IsNotExist(err) {
return nil, errors.New("No 'vendor' directory, can't use '-mod=vendor'")
return nil, errors.New("no 'vendor' directory, can't use '-mod=vendor'")
}
}
cmd = exec.CommandContext(ctx, "go", "list", "-mod=vendor", "-f", "'{{if not .Standard}}{{.Module}}{{end}}'", "-json", "-deps", "./...")
Expand All @@ -79,7 +72,7 @@ func runCmd(path string, mod bool) ([]byte, error) {
// mod=vendor sometimes still returns results but returns an error. In
// that case ignore the error and return what we can
if err != nil {
if mod == false {
if !mod {
// assume some retrival error, we have to redo the cmd with mod=vendor
return nil, err
} else {
Expand Down
2 changes: 1 addition & 1 deletion internal/scan/maven.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func GetMvnDeps(path string) (map[string]string, error) {
}
name = name[startIdx+4:]

if _, ok := found[name+ver]; ok == false {
if _, ok := found[name+ver]; !ok {
gathered[name] = ver
}
}
Expand Down
7 changes: 0 additions & 7 deletions internal/scan/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ import (
// Account for >, <, >=, <=, ==, !=, ~= and *
var /* const */ re = regexp.MustCompile(`[<>!~*]+`)

func max(x, y int) int {
if x > y {
return x
}
return y
}

func GetPythonDeps(path string) (map[string]string, error) {
gathered := make(map[string]string)

Expand Down

0 comments on commit a19191f

Please sign in to comment.