Skip to content

Commit

Permalink
Merge pull request #599 from Morganamilo/unused
Browse files Browse the repository at this point in the history
Remove unneeded variables
  • Loading branch information
Morganamilo authored Jul 30, 2018
2 parents 158e44c + 2a60dd7 commit 5f107ad
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
9 changes: 4 additions & 5 deletions cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,10 +398,8 @@ func handleGetpkgbuild() (err error) {
}

func handleYogurt() (err error) {
options := cmdArgs.formatArgs()

config.SearchMode = NumberMenu
err = numberMenu(cmdArgs.targets, options)
err = numberMenu(cmdArgs.targets)

return
}
Expand Down Expand Up @@ -445,7 +443,7 @@ func handleRemove() (err error) {
}

// NumberMenu presents a CLI for selecting packages to install.
func numberMenu(pkgS []string, flags []string) (err error) {
func numberMenu(pkgS []string) (err error) {
pkgS = removeInvalidTargets(pkgS)
var aurErr error
var repoErr error
Expand Down Expand Up @@ -538,7 +536,8 @@ func numberMenu(pkgS []string, flags []string) (err error) {
}

if len(arguments.targets) == 0 {
return fmt.Errorf("There is nothing to do")
fmt.Println("There is nothing to do")
return nil
}

if config.SudoLoop {
Expand Down
2 changes: 1 addition & 1 deletion download.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func gitDownload(url string, path string, name string) (bool, error) {
return false, nil
}

func gitMerge(url string, path string, name string) error {
func gitMerge(path string, name string) error {
err := show(passToGit(filepath.Join(path, name), "reset", "--hard", "HEAD"))
if err != nil {
return fmt.Errorf("error resetting %s", name)
Expand Down
28 changes: 14 additions & 14 deletions install.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func install(parser *arguments) error {

if config.CleanMenu {
askClean := pkgbuildNumberMenu(do.Aur, do.Bases, remoteNamesCache)
toClean, err := cleanNumberMenu(do.Aur, do.Bases, remoteNamesCache, askClean)
toClean, err := cleanNumberMenu(do.Aur, remoteNamesCache, askClean)
if err != nil {
return err
}
Expand All @@ -198,7 +198,7 @@ func install(parser *arguments) error {

if config.DiffMenu {
pkgbuildNumberMenu(do.Aur, do.Bases, remoteNamesCache)
toDiff, err = diffNumberMenu(do.Aur, do.Bases, remoteNamesCache)
toDiff, err = diffNumberMenu(do.Aur, remoteNamesCache)
if err != nil {
return err
}
Expand Down Expand Up @@ -234,13 +234,13 @@ func install(parser *arguments) error {

if config.EditMenu {
pkgbuildNumberMenu(do.Aur, do.Bases, remoteNamesCache)
toEdit, err = editNumberMenu(do.Aur, do.Bases, remoteNamesCache)
toEdit, err = editNumberMenu(do.Aur, remoteNamesCache)
if err != nil {
return err
}

if len(toEdit) > 0 {
err = editPkgBuilds(toEdit, srcinfosStale, do.Bases)
err = editPkgBuilds(toEdit, srcinfosStale)
if err != nil {
return err
}
Expand All @@ -257,7 +257,7 @@ func install(parser *arguments) error {
config.NoConfirm = oldValue
}

incompatible, err = getIncompatible(do.Aur, srcinfosStale, do.Bases)
incompatible, err = getIncompatible(do.Aur, srcinfosStale)
if err != nil {
return err
}
Expand Down Expand Up @@ -418,7 +418,7 @@ func earlyRefresh(parser *arguments) error {
return show(passToPacman(arguments))
}

func getIncompatible(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo, bases map[string][]*rpc.Pkg) (stringSet, error) {
func getIncompatible(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo) (stringSet, error) {
incompatible := make(stringSet)
alpmArch, err := alpmHandle.Arch()
if err != nil {
Expand Down Expand Up @@ -513,7 +513,7 @@ func pkgbuildNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed
return askClean
}

func cleanNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed stringSet, hasClean bool) ([]*rpc.Pkg, error) {
func cleanNumberMenu(pkgs []*rpc.Pkg, installed stringSet, hasClean bool) ([]*rpc.Pkg, error) {
toClean := make([]*rpc.Pkg, 0)

if !hasClean {
Expand Down Expand Up @@ -576,15 +576,15 @@ func cleanNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed str
return toClean, nil
}

func editNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed stringSet) ([]*rpc.Pkg, error) {
return editDiffNumberMenu(pkgs, bases, installed, false)
func editNumberMenu(pkgs []*rpc.Pkg, installed stringSet) ([]*rpc.Pkg, error) {
return editDiffNumberMenu(pkgs, installed, false)
}

func diffNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed stringSet) ([]*rpc.Pkg, error) {
return editDiffNumberMenu(pkgs, bases, installed, true)
func diffNumberMenu(pkgs []*rpc.Pkg, installed stringSet) ([]*rpc.Pkg, error) {
return editDiffNumberMenu(pkgs, installed, true)
}

func editDiffNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed stringSet, diff bool) ([]*rpc.Pkg, error) {
func editDiffNumberMenu(pkgs []*rpc.Pkg, installed stringSet, diff bool) ([]*rpc.Pkg, error) {
toEdit := make([]*rpc.Pkg, 0)
var editInput string
var err error
Expand Down Expand Up @@ -702,7 +702,7 @@ func showPkgBuildDiffs(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, cloned stri
return nil
}

func editPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo, bases map[string][]*rpc.Pkg) error {
func editPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo) error {
pkgbuilds := make([]string, 0, len(pkgs))
for _, pkg := range pkgs {
dir := filepath.Join(config.BuildDir, pkg.PackageBase)
Expand Down Expand Up @@ -786,7 +786,7 @@ func pkgBuildsToSkip(pkgs []*rpc.Pkg, targets stringSet) stringSet {
func mergePkgBuilds(pkgs []*rpc.Pkg) error {
for _, pkg := range pkgs {
if shouldUseGit(filepath.Join(config.BuildDir, pkg.PackageBase)) {
err := gitMerge(baseURL+"/"+pkg.PackageBase+".git", config.BuildDir, pkg.PackageBase)
err := gitMerge(config.BuildDir, pkg.PackageBase)
if err != nil {
return err
}
Expand Down
7 changes: 3 additions & 4 deletions upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) {

var repoErr error
var aurErr error
var develErr error

pkgdata := make(map[string]*rpc.Pkg)

Expand All @@ -145,7 +144,7 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) {
fmt.Println(bold(cyan("::") + bold(" Checking development packages...")))
wg.Add(1)
go func() {
develUp, develErr = upDevel(remote)
develUp = upDevel(remote)
wg.Done()
}()
}
Expand All @@ -156,7 +155,7 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) {
printLocalNewerThanAUR(remote, pkgdata)

errs := make([]string, 0)
for _, e := range []error{repoErr, aurErr, develErr} {
for _, e := range []error{repoErr, aurErr} {
if e != nil {
errs = append(errs, e.Error())
}
Expand Down Expand Up @@ -184,7 +183,7 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) {
return aurUp, repoUp, err
}

func upDevel(remote []alpm.Package) (toUpgrade upSlice, err error) {
func upDevel(remote []alpm.Package) (toUpgrade upSlice) {
toUpdate := make([]alpm.Package, 0)
toRemove := make([]string, 0)

Expand Down

0 comments on commit 5f107ad

Please sign in to comment.