Skip to content
This repository has been archived by the owner on Feb 26, 2019. It is now read-only.

Commit

Permalink
Address lint/vet issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Muller committed Jan 26, 2018
1 parent d5b8f3b commit e7f8f2f
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 86 deletions.
8 changes: 1 addition & 7 deletions godepfile.go
Expand Up @@ -25,10 +25,6 @@ type Godeps struct {
isOldFile bool
}

func createGodepsFile() (*os.File, error) {
return os.Create(godepsFile)
}

func loadGodepsFile(path string) (Godeps, error) {
var g Godeps
f, err := os.Open(path)
Expand Down Expand Up @@ -201,9 +197,7 @@ func (g *Godeps) addOrUpdateDeps(deps []Dependency) {
missing = append(missing, d)
}
}
for _, d := range missing {
g.Deps = append(g.Deps, d)
}
g.Deps = append(g.Deps, missing...)
}

func (g *Godeps) removeDeps(deps []Dependency) {
Expand Down
2 changes: 1 addition & 1 deletion license.go
Expand Up @@ -51,7 +51,7 @@ func IsLegalFile(filename string) bool {
}
}
for _, substring := range LegalFileSubstring {
if strings.Index(lowerfile, substring) != -1 {
if strings.Contains(lowerfile, substring) {
return true
}
}
Expand Down
7 changes: 2 additions & 5 deletions list.go
Expand Up @@ -54,10 +54,7 @@ func (ds *depScanner) Next() (*build.Package, string) {

// Continue looping?
func (ds *depScanner) Continue() bool {
if len(ds.todo) > 0 {
return true
}
return false
return len(ds.todo) > 0
}

// Add a package and imports to the depScanner. Skips already processed/pending package/import combos
Expand Down Expand Up @@ -94,7 +91,7 @@ func fullPackageInDir(dir string) (*build.Package, error) {
var err error
pkg, ok := pkgCache[dir]
if !ok {
pkg, err = build.ImportDir(dir, build.FindOnly)
pkg, _ = build.ImportDir(dir, build.FindOnly)
if pkg.Goroot {
pkg, err = build.ImportDir(pkg.Dir, 0)
} else {
Expand Down
20 changes: 0 additions & 20 deletions msg.go
Expand Up @@ -27,29 +27,9 @@ func debugf(format string, a ...interface{}) (int, error) {
return 0, nil
}

func verbosef(format string, a ...interface{}) {
if verbose {
log.Printf(format, a...)
}
}

func pp(a ...interface{}) (int, error) {
if debug {
return pretty.Print(a...)
}
return 0, nil
}

func ppln(a ...interface{}) (int, error) {
if debug {
return pretty.Println(a...)
}
return 0, nil
}

func ppf(format string, a ...interface{}) (int, error) {
if debug {
return pretty.Printf(format, a...)
}
return 0, nil
}
3 changes: 3 additions & 0 deletions rewrite.go
Expand Up @@ -98,6 +98,9 @@ func rewriteGoFile(name, qual string, paths []string) error {
}
fset = token.NewFileSet()
f, err = parser.ParseFile(fset, name, &buffer, parser.ParseComments)
if err != nil {
return err
}
ast.SortImports(fset, f)
tpath := name + ".temp"
t, err := os.Create(tpath)
Expand Down
24 changes: 0 additions & 24 deletions util.go
@@ -1,35 +1,11 @@
package main

import (
"fmt"
"os/exec"
"path/filepath"
"runtime"
"strings"
)

// Runs a command in dir.
// The name and args are as in exec.Command.
// Stdout, stderr, and the environment are inherited
// from the current process.
func runIn(dir, name string, args ...string) error {
_, err := runInWithOutput(dir, name, args...)
return err
}

func runInWithOutput(dir, name string, args ...string) (string, error) {
c := exec.Command(name, args...)
c.Dir = dir
o, err := c.CombinedOutput()

if debug {
fmt.Printf("execute: %+v\n", c)
fmt.Printf(" output: %s\n", string(o))
}

return string(o), err
}

// driveLetterToUpper converts Windows path's drive letters to uppercase. This
// is needed when comparing 2 paths with different drive letter case.
func driveLetterToUpper(path string) string {
Expand Down
29 changes: 0 additions & 29 deletions vcs.go
Expand Up @@ -79,19 +79,6 @@ func VCSFromDir(dir, srcRoot string) (*VCS, string, error) {
return vcsext, reporoot, nil
}

// VCSForImportPath returns a VCS value for an import path.
func VCSForImportPath(importPath string) (*VCS, error) {
rr, err := vcs.RepoRootForImportPath(importPath, debug)
if err != nil {
return nil, err
}
vcs := cmd[rr.VCS]
if vcs == nil {
return nil, fmt.Errorf("%s is unsupported: %s", rr.VCS.Name, importPath)
}
return vcs, nil
}

func (v *VCS) identify(dir string) (string, error) {
out, err := v.runOutput(dir, v.IdentifyCmd)
return string(bytes.TrimSpace(out)), err
Expand Down Expand Up @@ -260,22 +247,6 @@ func expand(m map[string]string, s string) string {
return s
}

// Mercurial has no command equivalent to git remote add.
// We handle it as a special case in process.
func hgLink(dir, remote, url string) error {
hgdir := filepath.Join(dir, ".hg")
if err := os.MkdirAll(hgdir, 0777); err != nil {
return err
}
path := filepath.Join(hgdir, "hgrc")
f, err := os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
if err != nil {
return err
}
fmt.Fprintf(f, "[paths]\n%s = %s\n", remote, url)
return f.Close()
}

func gitDetached(r string) (bool, error) {
o, err := vcsGit.runOutput(r, "status")
if err != nil {
Expand Down

0 comments on commit e7f8f2f

Please sign in to comment.