Skip to content

Commit

Permalink
Fix gofmt and travis
Browse files Browse the repository at this point in the history
 - Changes to travis.yml
 - New hack validate-gofmt.bash script
 - Fixing staticcheck in gps
 - Fixing gosimple in gps
  • Loading branch information
krisnova committed Apr 25, 2017
1 parent 38bd1da commit 0561ca9
Show file tree
Hide file tree
Showing 29 changed files with 71 additions and 35 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ script:
# Ignore the deprecation warning about filepath.HasPrefix (SA1019). This flag
# can be removed when issue #296 is resolved.
- staticcheck -ignore='github.com/golang/dep/context.go:SA1019 github.com/golang/dep/cmd/dep/init.go:SA1019 github.com/golang/dep/cmd/dep/status.go:SA4010' $PKGS
#- test -z "$(gofmt -s -l . 2>&1 | grep -v vendor/ | tee /dev/stderr)"
- find * -maxdepth 1 ! -path "testdata" ! -path "vendor" ! -path "gps/_testdata" -type d -print0 | xargs -0 gofmt -s -l
- ./hack/validate-gofmt.bash
- ./hack/validate-vendor.bash
- gosimple $PKGS
- go test -race $PKGS
- go build ./hack/licenseok
- find . -path ./vendor -prune -o -type f -name "*.go" -printf '%P\n' | xargs ./licenseok
- ./hack/validate-vendor.bash

4 changes: 2 additions & 2 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
"strings"

"github.com/golang/dep"
"github.com/golang/dep/internal"
"github.com/pkg/errors"
"github.com/golang/dep/gps"
"github.com/golang/dep/gps/pkgtree"
"github.com/golang/dep/internal"
"github.com/pkg/errors"
)

const ensureShortHelp = `Ensure a dependency is safely vendored in the project`
Expand Down
2 changes: 1 addition & 1 deletion cmd/dep/hash_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"fmt"

"github.com/golang/dep"
"github.com/pkg/errors"
"github.com/golang/dep/gps"
"github.com/golang/dep/gps/pkgtree"
"github.com/pkg/errors"
)

func (cmd *hashinCommand) Name() string { return "hash-inputs" }
Expand Down
4 changes: 2 additions & 2 deletions cmd/dep/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"strings"

"github.com/golang/dep"
"github.com/golang/dep/internal"
"github.com/pkg/errors"
"github.com/golang/dep/gps"
"github.com/golang/dep/gps/pkgtree"
"github.com/golang/dep/internal"
"github.com/pkg/errors"
)

const initShortHelp = `Initialize a new project with manifest and lock files`
Expand Down
4 changes: 2 additions & 2 deletions cmd/dep/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
"strings"

"github.com/golang/dep"
"github.com/golang/dep/internal"
"github.com/pkg/errors"
"github.com/golang/dep/gps"
"github.com/golang/dep/gps/pkgtree"
"github.com/golang/dep/internal"
"github.com/pkg/errors"
)

const removeShortHelp = `Remove a dependency from the project`
Expand Down
2 changes: 1 addition & 1 deletion cmd/dep/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
"text/tabwriter"

"github.com/golang/dep"
"github.com/pkg/errors"
"github.com/golang/dep/gps"
"github.com/golang/dep/gps/pkgtree"
"github.com/pkg/errors"
)

const statusShortHelp = `Report the status of the project's dependencies`
Expand Down
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"strings"

"github.com/Masterminds/vcs"
"github.com/pkg/errors"
"github.com/golang/dep/gps"
"github.com/pkg/errors"
)

// Ctx defines the supporting context of the tool.
Expand Down
2 changes: 1 addition & 1 deletion context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"testing"
"unicode"

"github.com/golang/dep/test"
"github.com/golang/dep/gps"
"github.com/golang/dep/test"
)

func TestNewContextNoGOPATH(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion gps/_testdata/src/disallow/a.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package disallow

import (
"sort"
"disallow/testdata"
"sort"

"github.com/golang/dep/gps"
)
Expand Down
2 changes: 1 addition & 1 deletion gps/_testdata/src/missing/a.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package simple
import (
"sort"

"missing/missing"
"github.com/golang/dep/gps"
"missing/missing"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion gps/deduce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ func TestVanityDeduction(t *testing.T) {
do := func(t *testing.T) {
for _, fix := range vanities {
fix := fix
t.Run(fmt.Sprintf("%s", fix.in), func(t *testing.T) {
t.Run(fix.in, func(t *testing.T) {
t.Parallel()

pr, err := sm.DeduceProjectRoot(fix.in)
Expand Down
1 change: 0 additions & 1 deletion gps/internal/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,3 @@ func CopyFile(src, dst string) (err error) {

return
}

1 change: 0 additions & 1 deletion gps/internal/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,3 @@ func TestIsStdLib(t *testing.T) {
}
}
}

2 changes: 1 addition & 1 deletion gps/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ func TestSupervisor(t *testing.T) {
}()

<-wait
err = <- errchan
err = <-errchan
if err != nil {
t.Fatal("unexpected err on do() completion:", err)
}
Expand Down
4 changes: 2 additions & 2 deletions gps/pkgtree/pkgtree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1839,8 +1839,8 @@ func TestFlattenReachMap(t *testing.T) {
name = "ignore external"
ignore = map[string]bool{
"github.com/golang/dep/gps": true,
"go/parser": true,
"sort": true,
"go/parser": true,
"sort": true,
}
except("sort", "github.com/golang/dep/gps", "go/parser")
validate()
Expand Down
2 changes: 1 addition & 1 deletion gps/pkgtree/reachmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ func (rm ReachMap) flatten(filter func(string) bool, stdlib bool) []string {

sort.Strings(ex)
return ex
}
}
4 changes: 2 additions & 2 deletions gps/source_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"sync/atomic"
"time"

"github.com/sdboyer/constext"
"github.com/golang/dep/gps/pkgtree"
"github.com/sdboyer/constext"
)

// Used to compute a friendly filepath from a URL-shaped input.
Expand Down Expand Up @@ -535,7 +535,7 @@ func (sup *supervisor) done(ci callInfo) {
// Last one for this particular key; update metrics with info.
durCnt := sup.ran[ci.typ]
durCnt.count++
durCnt.dur += time.Now().Sub(existingInfo.start)
durCnt.dur += time.Since(existingInfo.start)
sup.ran[ci.typ] = durCnt
delete(sup.running, ci)

Expand Down
2 changes: 1 addition & 1 deletion gps/vcs_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (s *gitSource) listVersions(ctx context.Context) (vlist []PairedVersion, er
for k, v := range vlist {
pv := v.(PairedVersion)
if bv, ok := pv.Unpair().(branchVersion); ok {
if bv.name != "master" && bv.isDefault == true {
if bv.name != "master" && bv.isDefault {
bv.isDefault = false
vlist[k] = bv.Is(pv.Underlying())
}
Expand Down
38 changes: 38 additions & 0 deletions hack/validate-gofmt.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash
# Copyright 2017 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
#
# This script will validate that `go fmt` has been ran
# and is passing for certain directories in the project.
#
# Here we use `go list` to help determine which packages
# we need to check for `go gmt`
#
# EXIT 0 - The check is successful
# EXIT 1 - The check has failed

PKGS=$(go list ./... | grep -v /vendor/)
REPO_TLD="github.com/golang/dep"
IGNORE_PKGS=". ./gps"

for PKG in $PKGS; do
RELATIVE_PATH="${PKG/$REPO_TLD/.}"
i=0
for IGNORE_PKG in $IGNORE_PKGS; do
if [ "${IGNORE_PKG}" == $RELATIVE_PATH ]; then
i=1
fi
done;
if [ $i -eq 1 ]; then
continue
fi

echo "Processing gofmt for: ${PKG}"
gofmt -s -l $RELATIVE_PATH
if [ $? -ne 0 ]; then
echo "GO FMT FAILURE: ${PKG}"
exit 1
fi
done;
exit 0
2 changes: 1 addition & 1 deletion lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"sort"

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

const LockName = "Gopkg.lock"
Expand Down
2 changes: 1 addition & 1 deletion lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"strings"
"testing"

"github.com/golang/dep/test"
"github.com/golang/dep/gps"
"github.com/golang/dep/test"
)

func TestReadLock(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (

"bytes"

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

const ManifestName = "Gopkg.toml"
Expand Down
2 changes: 1 addition & 1 deletion manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"
"testing"

"github.com/golang/dep/test"
"github.com/golang/dep/gps"
"github.com/golang/dep/test"
)

func TestReadManifest(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion project.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"os"
"path/filepath"

"github.com/pkg/errors"
"github.com/golang/dep/gps"
"github.com/pkg/errors"
)

var errProjectNotFound = fmt.Errorf("could not find project %s, use dep init to initiate a manifest", ManifestName)
Expand Down
2 changes: 1 addition & 1 deletion project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"runtime"
"testing"

"github.com/golang/dep/test"
"github.com/golang/dep/gps"
"github.com/golang/dep/test"
)

func TestFindRoot(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test_project_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ package dep
import (
"path/filepath"

"github.com/golang/dep/gps"
"github.com/golang/dep/test"
"github.com/pkg/errors"
"github.com/golang/dep/gps"
)

// TestProjectContext groups together test project files and helps test them
Expand Down
2 changes: 1 addition & 1 deletion txn_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"sort"
"strings"

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

// SafeWriter transactionalizes writes of manifest, lock, and vendor dir, both
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/pelletier/go-toml/tomltree_write.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0561ca9

Please sign in to comment.