Use megacheck to lint project

Signed-off-by: Jguer <me@jguer.space>
This commit is contained in:
Jguer 2018-04-27 01:25:40 +01:00
parent 66362aa981
commit d319576303
8 changed files with 15 additions and 22 deletions

View file

@ -21,11 +21,7 @@ func shouldUseGit(path string) bool {
}
_, err = os.Stat(filepath.Join(path, ".git"))
if os.IsNotExist(err) {
return false
}
return true
return os.IsExist(err)
}
func downloadFile(path string, url string) (err error) {

View file

@ -2,6 +2,7 @@ package main
import (
"bytes"
"context"
"fmt"
"io/ioutil"
"net/http"
@ -36,10 +37,6 @@ func newPkg(basename string) *rpc.Pkg {
return &rpc.Pkg{Name: basename, PackageBase: basename}
}
func newSplitPkg(basename, name string) *rpc.Pkg {
return &rpc.Pkg{Name: name, PackageBase: basename}
}
func getPgpKey(key string) string {
var buffer bytes.Buffer
@ -73,7 +70,7 @@ func TestImportKeys(t *testing.T) {
config.GpgFlags = fmt.Sprintf("--homedir %s --keyserver 127.0.0.1", keyringDir)
server := startPgpKeyServer()
defer server.Shutdown(nil)
defer server.Shutdown(context.TODO())
casetests := []struct {
keys []string
@ -138,7 +135,7 @@ func TestCheckPgpKeys(t *testing.T) {
config.GpgFlags = fmt.Sprintf("--homedir %s --keyserver 127.0.0.1", keyringDir)
server := startPgpKeyServer()
defer server.Shutdown(nil)
defer server.Shutdown(context.TODO())
casetests := []struct {
pkgs []*rpc.Pkg

View file

@ -220,7 +220,7 @@ func (parser *arguments) getArg(options ...string) (arg string, double bool, exi
existCount := 0
for _, option := range options {
arg, exists = parser.options[option]
_, exists = parser.options[option]
if exists {
existCount++
@ -619,8 +619,8 @@ func (parser *arguments) parseCommandLine() (err error) {
//of course the implementation is up to the caller, this function mearley parses
//the input and organizes it
func parseNumberMenu(input string) (intRanges, intRanges, stringSet, stringSet) {
include := make(intRanges, 0, 0)
exclude := make(intRanges, 0, 0)
include := make(intRanges, 0)
exclude := make(intRanges, 0)
otherInclude := make(stringSet)
otherExclude := make(stringSet)

View file

@ -19,7 +19,7 @@ func intRangesEqual(a, b intRanges) bool {
r1 := a[n]
r2 := b[n]
if r1.min != r1.min || r1.max != r2.max {
if r1.min != r2.min || r1.max != r2.max {
return false
}
}

View file

@ -341,6 +341,10 @@ func printUpdateList(parser *arguments) error {
old := os.Stdout // keep backup of the real stdout
os.Stdout = nil
_, _, localNames, remoteNames, err := filterPackages()
if err != nil {
return err
}
aurUp, repoUp, err := upList(warnings)
os.Stdout = old // restoring the real stdout
if err != nil {

View file

@ -353,7 +353,7 @@ func hangingPackages(removeOptional bool) (hanging []string, err error) {
iterateAgain := true
processDependencies := func(pkg alpm.Package) error {
if state, _ := safePackages[pkg.Name()]; state == 0 || state == 2 {
if state := safePackages[pkg.Name()]; state == 0 || state == 2 {
return nil
}

View file

@ -193,8 +193,8 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) {
}
func upDevel(remote []alpm.Package) (toUpgrade upSlice, err error) {
toUpdate := make([]alpm.Package, 0, 0)
toRemove := make([]string, 0, 0)
toUpdate := make([]alpm.Package, 0)
toRemove := make([]string, 0)
var mux1 sync.Mutex
var mux2 sync.Mutex

4
vcs.go
View file

@ -205,10 +205,6 @@ func (infos shaInfos) needsUpdate() bool {
}
}
func inStore(pkgName string) shaInfos {
return savedInfo[pkgName]
}
func saveVCSInfo() error {
marshalledinfo, err := json.MarshalIndent(savedInfo, "", "\t")
if err != nil || string(marshalledinfo) == "null" {