aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/beku/command.go14
-rw-r--r--env.go19
-rw-r--r--go/vcs/vcs.go2
-rw-r--r--go/vcs/vcs_test.go1
-rw-r--r--package.go24
5 files changed, 14 insertions, 46 deletions
diff --git a/cmd/beku/command.go b/cmd/beku/command.go
index fce475d..00e292c 100644
--- a/cmd/beku/command.go
+++ b/cmd/beku/command.go
@@ -279,7 +279,7 @@ func (cmd *command) parseLongFlags(arg string) (op operation, err error) {
//
// parseFlags for multiple operations, invalid options, or empty targets.
//
-func (cmd *command) parseFlags(args []string) (err error) {
+func (cmd *command) parseFlags(args []string) (err error) { //nolint: gocognit
if len(args) == 0 {
return errNoOperation
}
@@ -334,10 +334,8 @@ func (cmd *command) parseFlags(args []string) (err error) {
return errInvalidOptions
}
- if cmd.op&opSyncInto == opSyncInto {
- if cmd.op&opSync != opSync {
- return errInvalidOptions
- }
+ if (cmd.op&opSyncInto == opSyncInto) && (cmd.op&opSync != opSync) {
+ return errInvalidOptions
}
// Only one operation is allowed.
@@ -348,10 +346,8 @@ func (cmd *command) parseFlags(args []string) (err error) {
}
// "-R" or "-S" must have target
- if op == opRemove {
- if len(cmd.pkgs) == 0 {
- return errNoTarget
- }
+ if op == opRemove && len(cmd.pkgs) == 0 {
+ return errNoTarget
}
return nil
diff --git a/env.go b/env.go
index 541a4b1..c9776a6 100644
--- a/env.go
+++ b/env.go
@@ -55,10 +55,8 @@ type Env struct {
// NewEnvironment will gather all information in user system.
//
func NewEnvironment(vendor, noDeps bool) (env *Env, err error) {
- if !vendor {
- if len(build.Default.GOPATH) == 0 {
- vendor = true
- }
+ if !vendor && len(build.Default.GOPATH) == 0 {
+ vendor = true
}
if len(build.Default.GOROOT) == 0 {
return nil, ErrGOROOT
@@ -135,19 +133,6 @@ func (env *Env) addExclude(importPath string) bool {
return true
}
-func (env *Env) cleanUnused() {
- for _, pkg := range env.pkgsUnused {
- fmt.Println("[ENV] cleanUnused >>>", pkg.FullPath)
- _ = pkg.Remove()
-
- pkgPath := filepath.Join(env.dirPkg, pkg.ImportPath)
-
- fmt.Println("[ENV] cleanUnused >>>", pkgPath)
- _ = os.RemoveAll(pkgPath)
- _ = libio.RmdirEmptyAll(pkgPath)
- }
-}
-
//
// Exclude mark list of packages to be excluded from future operations.
//
diff --git a/go/vcs/vcs.go b/go/vcs/vcs.go
index 471f841..2e2df04 100644
--- a/go/vcs/vcs.go
+++ b/go/vcs/vcs.go
@@ -212,7 +212,7 @@ func (v *Cmd) run1(dir string, cmdline string, keyval []string, verbose bool) ([
return nil, err
}
- cmd := exec.Command(v.Cmd, args...)
+ cmd := exec.Command(v.Cmd, args...) //nolint: gosec
cmd.Dir = dir
cmd.Env = envForDir(cmd.Dir)
if ShowCmd {
diff --git a/go/vcs/vcs_test.go b/go/vcs/vcs_test.go
index d17caad..a495032 100644
--- a/go/vcs/vcs_test.go
+++ b/go/vcs/vcs_test.go
@@ -17,7 +17,6 @@ import (
)
// Test that RepoRootForImportPath creates the correct RepoRoot for a given importPath.
-// TODO(cmang): Add tests for SVN and BZR.
func TestRepoRootForImportPath(t *testing.T) {
if runtime.GOOS == "android" {
t.Skipf("incomplete source tree on %s", runtime.GOOS)
diff --git a/package.go b/package.go
index 255b8f0..2bd5467 100644
--- a/package.go
+++ b/package.go
@@ -91,9 +91,7 @@ func (pkg *Package) CheckoutVersion(newVersion string) (err error) {
}
err = git.CheckoutRevision(pkg.FullPath, pkg.RemoteName, pkg.RemoteBranch, newVersion)
}
-
return
-
}
//
@@ -433,12 +431,7 @@ func (pkg *Package) addDep(env *Env, importPath string) bool {
// load package metadata from database (INI Section).
//
func (pkg *Package) load(sec *ini.Section) {
- switch sec.Val(keyVCSMode) {
- case VCSModeGit:
- pkg.vcsMode = VCSModeGit
- default:
- pkg.vcsMode = VCSModeGit
- }
+ pkg.vcsMode = VCSModeGit
pkg.RemoteName = sec.Val(keyRemoteName)
pkg.RemoteURL = sec.Val(keyRemoteURL)
@@ -598,12 +591,12 @@ func (pkg *Package) UpdateMissingDep(newPkg *Package, addAsDep bool) (found bool
//
// pushDep will append import path into list of dependencies only if it's not
-// exist. If import path exist it will return false.
+// exist.
//
-func (pkg *Package) pushDep(importPath string) bool {
+func (pkg *Package) pushDep(importPath string) {
for x := 0; x < len(pkg.Deps); x++ {
if importPath == pkg.Deps[x] {
- return false
+ return
}
}
@@ -613,23 +606,18 @@ func (pkg *Package) pushDep(importPath string) bool {
fmt.Printf("[PKG] pushDep %s >>> %s\n", pkg.ImportPath,
importPath)
}
-
- return true
}
//
// pushMissing import path only if not exist yet.
//
-func (pkg *Package) pushMissing(importPath string) bool {
+func (pkg *Package) pushMissing(importPath string) {
for x := 0; x < len(pkg.DepsMissing); x++ {
if pkg.DepsMissing[x] == importPath {
- return false
+ return
}
}
-
pkg.DepsMissing = append(pkg.DepsMissing, importPath)
-
- return true
}
//