Skip to content

Commit

Permalink
[FIX] Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
im-kulikov committed Feb 11, 2018
1 parent a891ec1 commit f518253
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 35 deletions.
2 changes: 1 addition & 1 deletion cmd/dep/ensure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func TestValidateUpdateArgs(t *testing.T) {
stderrOutput.Reset()

// Fill up the locked projects
lockedProjects := []gps.LockedProject{}
lockedProjects := make([]gps.LockedProject, 0, len(c.lockedProjects))
for _, lp := range c.lockedProjects {
pi := gps.ProjectIdentifier{ProjectRoot: gps.ProjectRoot(lp)}
lockedProjects = append(lockedProjects, gps.NewLockedProject(pi, gps.NewVersion("v1.0.0"), []string{}))
Expand Down
4 changes: 2 additions & 2 deletions cmd/dep/gopath_scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/golang/dep/internal/test"
)

const testProject1 string = "github.com/sdboyer/deptest"
const testProject2 string = "github.com/sdboyer/deptestdos"
const testProject1 = "github.com/sdboyer/deptest"
const testProject2 = "github.com/sdboyer/deptestdos"

// NewTestContext creates a unique context with its own GOPATH for a single test.
func NewTestContext(h *test.Helper) *dep.Ctx {
Expand Down
2 changes: 1 addition & 1 deletion cmd/dep/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ fail:
func calculatePrune(vendorDir string, keep []string, logger *log.Logger) ([]string, error) {
logger.Println("Calculating prune. Checking the following packages:")
sort.Strings(keep)
toDelete := []string{}
var toDelete []string
err := filepath.Walk(vendorDir, func(path string, info os.FileInfo, err error) error {
if _, err := os.Lstat(path); err != nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/dep/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {

func (cmd *statusCommand) validateFlags() error {
// Operating mode flags.
opModes := []string{}
var opModes []string

if cmd.old {
opModes = append(opModes, "-old")
Expand Down
3 changes: 1 addition & 2 deletions cmd/dep/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import (
"log"
"path/filepath"
"reflect"
"strings"
"testing"
"text/tabwriter"

"strings"

"github.com/golang/dep"
"github.com/golang/dep/gps"
"github.com/golang/dep/internal/test"
Expand Down
2 changes: 1 addition & 1 deletion gps/_testdata/src/relimport/dotdot/a.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package dotdot

import (
relimport ".."
".."
)

var (
Expand Down
2 changes: 1 addition & 1 deletion gps/deduce.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"strings"
"sync"

radix "github.com/armon/go-radix"
"github.com/armon/go-radix"
"github.com/pkg/errors"
)

Expand Down
12 changes: 6 additions & 6 deletions gps/filesystem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func TestDeriveFilesystemState(t *testing.T) {
"simple-file",
},
links: []fsLink{
fsLink{
{
path: "link",
to: "nonexisting",
broken: true,
Expand All @@ -150,7 +150,7 @@ func TestDeriveFilesystemState(t *testing.T) {
"simple-file",
},
links: []fsLink{
fsLink{
{
path: "link",
to: "",
broken: true,
Expand All @@ -164,12 +164,12 @@ func TestDeriveFilesystemState(t *testing.T) {
fs: fsTestCase{
before: filesystemState{
links: []fsLink{
fsLink{
{
path: "link1",
to: "link2",
circular: true,
},
fsLink{
{
path: "link2",
to: "link1",
circular: true,
Expand All @@ -178,12 +178,12 @@ func TestDeriveFilesystemState(t *testing.T) {
},
after: filesystemState{
links: []fsLink{
fsLink{
{
path: "link1",
to: "",
circular: true,
},
fsLink{
{
path: "link2",
to: "",
circular: true,
Expand Down
14 changes: 7 additions & 7 deletions gps/solve_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ func (sm *depspecSourceManager) GetManifestAndLock(id ProjectIdentifier, v Versi
}
}

return nil, nil, fmt.Errorf("Project %s at version %s could not be found", id, v)
return nil, nil, fmt.Errorf("project %s at version %s could not be found", id, v)
}

func (sm *depspecSourceManager) ListPackages(id ProjectIdentifier, v Version) (pkgtree.PackageTree, error) {
Expand Down Expand Up @@ -1404,7 +1404,7 @@ func (sm *depspecSourceManager) ListPackages(id ProjectIdentifier, v Version) (p
}
}

return pkgtree.PackageTree{}, fmt.Errorf("Project %s at version %s could not be found", pid.n, v)
return pkgtree.PackageTree{}, fmt.Errorf("project %s at version %s could not be found", pid.n, v)
}

func (sm *depspecSourceManager) ListVersions(id ProjectIdentifier) ([]PairedVersion, error) {
Expand All @@ -1431,7 +1431,7 @@ func (sm *depspecSourceManager) ListVersions(id ProjectIdentifier) ([]PairedVers
}

if len(pvl) == 0 {
return nil, fmt.Errorf("Project %s could not be found", id)
return nil, fmt.Errorf("project %s could not be found", id)
}
return pvl, nil
}
Expand All @@ -1444,7 +1444,7 @@ func (sm *depspecSourceManager) RevisionPresentIn(id ProjectIdentifier, r Revisi
}
}

return false, fmt.Errorf("Project %s has no revision %s", id, r)
return false, fmt.Errorf("project %s has no revision %s", id, r)
}

func (sm *depspecSourceManager) SourceExists(id ProjectIdentifier) (bool, error) {
Expand All @@ -1461,7 +1461,7 @@ func (sm *depspecSourceManager) SourceExists(id ProjectIdentifier) (bool, error)
func (sm *depspecSourceManager) SyncSourceFor(id ProjectIdentifier) error {
// Ignore err because it can't happen
if exist, _ := sm.SourceExists(id); !exist {
return fmt.Errorf("Source %s does not exist", id)
return fmt.Errorf("source %s does not exist", id)
}
return nil
}
Expand All @@ -1480,7 +1480,7 @@ func (sm *depspecSourceManager) DeduceProjectRoot(ip string) (ProjectRoot, error
return ProjectRoot(ip[:len(n)]), nil
}
}
return "", fmt.Errorf("Could not find %s, or any parent, in list of known fixtures", ip)
return "", fmt.Errorf("could not find %s, or any parent, in list of known fixtures", ip)
}

func (sm *depspecSourceManager) SourceURLsForPath(ip string) ([]*url.URL, error) {
Expand Down Expand Up @@ -1547,7 +1547,7 @@ func (b *depspecBridge) listVersions(id ProjectIdentifier) ([]Version, error) {
func (b *depspecBridge) verifyRootDir(path string) error {
root := b.sm.(fixSM).rootSpec()
if string(root.n) != path {
return fmt.Errorf("Expected only root project %q to verifyRootDir(), got %q", root.n, path)
return fmt.Errorf("expected only root project %q to verifyRootDir(), got %q", root.n, path)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions gps/solve_bimodal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ func (sm *bmSourceManager) ListPackages(id ProjectIdentifier, v Version) (pkgtre
}
}

return pkgtree.PackageTree{}, fmt.Errorf("Project %s at version %s could not be found", id, v)
return pkgtree.PackageTree{}, fmt.Errorf("project %s at version %s could not be found", id, v)
}

func (sm *bmSourceManager) GetManifestAndLock(id ProjectIdentifier, v Version, an ProjectAnalyzer) (Manifest, Lock, error) {
Expand All @@ -1460,7 +1460,7 @@ func (sm *bmSourceManager) GetManifestAndLock(id ProjectIdentifier, v Version, a
}

// TODO(sdboyer) proper solver-type errors
return nil, nil, fmt.Errorf("Project %s at version %s could not be found", id, v)
return nil, nil, fmt.Errorf("project %s at version %s could not be found", id, v)
}

// computeBimodalExternalMap takes a set of depspecs and computes an
Expand Down
2 changes: 1 addition & 1 deletion hack/licenseok/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func addLicense(b []byte, path string, fmode os.FileMode) error {
}

func hashBang(b []byte) []byte {
var line []byte
var line = make([]byte, 0, len(b))
for _, c := range b {
line = append(line, c)
if c == '\n' {
Expand Down
2 changes: 1 addition & 1 deletion internal/importers/base/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (i *Importer) lookupVersionForLockedProject(pi gps.ProjectIdentifier, c gps

var branchConstraint gps.PairedVersion
gps.SortPairedForUpgrade(versions) // Sort versions in asc order
matches := []gps.Version{}
var matches []gps.Version
for _, v := range versions {
if v.Revision() == rev {
matches = append(matches, v)
Expand Down
2 changes: 1 addition & 1 deletion internal/test/integration/testproj.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

const (
projectRoot string = "src/github.com/golang/notexist"
projectRoot = "src/github.com/golang/notexist"
)

// RunFunc defines the function signature for an integration test command to execute.
Expand Down
4 changes: 2 additions & 2 deletions internal/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ var (
)

const (
manifestName string = "Gopkg.toml"
lockName string = "Gopkg.lock"
manifestName = "Gopkg.toml"
lockName = "Gopkg.lock"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

"github.com/golang/dep/gps"
"github.com/golang/dep/gps/pkgtree"
toml "github.com/pelletier/go-toml"
"github.com/pelletier/go-toml"
"github.com/pkg/errors"
)

Expand Down
10 changes: 5 additions & 5 deletions manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func TestCheckRedundantPruneOptions(t *testing.T) {
pruneOptions: gps.CascadingPruneOptions{
DefaultOptions: 15,
PerProjectOptions: map[gps.ProjectRoot]gps.PruneOptionSet{
"github.com/golang/dep": gps.PruneOptionSet{
"github.com/golang/dep": {
NestedVendor: pvtrue,
UnusedPackages: pvtrue,
NonGoFiles: pvtrue,
Expand All @@ -495,7 +495,7 @@ func TestCheckRedundantPruneOptions(t *testing.T) {
pruneOptions: gps.CascadingPruneOptions{
DefaultOptions: 1,
PerProjectOptions: map[gps.ProjectRoot]gps.PruneOptionSet{
"github.com/golang/dep": gps.PruneOptionSet{
"github.com/golang/dep": {
NestedVendor: pvtrue,
UnusedPackages: pvfalse,
NonGoFiles: pvfalse,
Expand All @@ -514,12 +514,12 @@ func TestCheckRedundantPruneOptions(t *testing.T) {
pruneOptions: gps.CascadingPruneOptions{
DefaultOptions: 7,
PerProjectOptions: map[gps.ProjectRoot]gps.PruneOptionSet{
"github.com/golang/dep": gps.PruneOptionSet{
"github.com/golang/dep": {
NestedVendor: pvtrue,
NonGoFiles: pvtrue,
GoTests: pvtrue,
},
"github.com/other/project": gps.PruneOptionSet{
"github.com/other/project": {
NestedVendor: pvtrue,
UnusedPackages: pvfalse,
GoTests: pvfalse,
Expand Down Expand Up @@ -798,7 +798,7 @@ func TestToRawPruneOptions_Panic(t *testing.T) {
pruneOptions := gps.CascadingPruneOptions{
DefaultOptions: 1,
PerProjectOptions: map[gps.ProjectRoot]gps.PruneOptionSet{
"github.com/carolynvs/deptest": gps.PruneOptionSet{
"github.com/carolynvs/deptest": {
NestedVendor: pvtrue,
},
},
Expand Down

0 comments on commit f518253

Please sign in to comment.