diff options
| author | Shulhan <m.shulhan@gmail.com> | 2019-12-27 21:45:51 +0700 |
|---|---|---|
| committer | Shulhan <m.shulhan@gmail.com> | 2019-12-27 21:45:51 +0700 |
| commit | b5f28512de8cf3fcc7fe31fb7c11570816f86a0f (patch) | |
| tree | 9eb797f2f751e339f62c38129d6668ba244a0f4b | |
| parent | a35233a2804d6112077157bd15038662107eb2ac (diff) | |
| download | beku-b5f28512de8cf3fcc7fe31fb7c11570816f86a0f.tar.xz | |
all: fix linter warnings
| -rw-r--r-- | cmd/beku/command.go | 14 | ||||
| -rw-r--r-- | env.go | 19 | ||||
| -rw-r--r-- | go/vcs/vcs.go | 2 | ||||
| -rw-r--r-- | go/vcs/vcs_test.go | 1 | ||||
| -rw-r--r-- | package.go | 24 |
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 @@ -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) @@ -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 } // |
