Merge pull request #1673 from im-kulikov/fix-000-cleanup-code

[FIX] Cleanup code
This commit is contained in:
sam boyer 2018-02-11 11:28:05 -05:00 коммит произвёл GitHub
Родитель c09bba70dc 2f5dec17a7
Коммит 8add10611c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
15 изменённых файлов: 33 добавлений и 34 удалений

Просмотреть файл

@ -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{}))

Просмотреть файл

@ -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 {

Просмотреть файл

@ -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

Просмотреть файл

@ -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")

Просмотреть файл

@ -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"

Просмотреть файл

@ -16,7 +16,7 @@ import (
"strings"
"sync"
radix "github.com/armon/go-radix"
"github.com/armon/go-radix"
"github.com/pkg/errors"
)

Просмотреть файл

@ -135,7 +135,7 @@ func TestDeriveFilesystemState(t *testing.T) {
"simple-file",
},
links: []fsLink{
fsLink{
{
path: "link",
to: "nonexisting",
broken: true,
@ -150,7 +150,7 @@ func TestDeriveFilesystemState(t *testing.T) {
"simple-file",
},
links: []fsLink{
fsLink{
{
path: "link",
to: "",
broken: true,
@ -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,
@ -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,

Просмотреть файл

@ -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) {
@ -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) {
@ -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
}
@ -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) {
@ -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
}
@ -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) {
@ -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

Просмотреть файл

@ -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) {
@ -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

Просмотреть файл

@ -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' {

Просмотреть файл

@ -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)

Просмотреть файл

@ -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.

Просмотреть файл

@ -34,8 +34,8 @@ var (
)
const (
manifestName string = "Gopkg.toml"
lockName string = "Gopkg.lock"
manifestName = "Gopkg.toml"
lockName = "Gopkg.lock"
)
func init() {

Просмотреть файл

@ -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"
)

Просмотреть файл

@ -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,
@ -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,
@ -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,
@ -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,
},
},