Merge pull request #6975 from gyuho/gopath

*: fix 'gosimple', 'gounused' checks
This commit is contained in:
Gyu-Ho Lee 2016-12-12 11:53:45 -08:00 committed by GitHub
commit be740dc436
12 changed files with 12 additions and 50 deletions

View File

@ -459,11 +459,7 @@ func (as *authStore) UserGet(r *pb.AuthUserGetRequest) (*pb.AuthUserGetResponse,
if user == nil {
return nil, ErrUserNotFound
}
for _, role := range user.Roles {
resp.Roles = append(resp.Roles, role)
}
resp.Roles = append(resp.Roles, user.Roles...)
return &resp, nil
}
@ -529,11 +525,7 @@ func (as *authStore) RoleGet(r *pb.AuthRoleGetRequest) (*pb.AuthRoleGetResponse,
if role == nil {
return nil, ErrRoleNotFound
}
for _, perm := range role.KeyPermission {
resp.Perm = append(resp.Perm, perm)
}
resp.Perm = append(resp.Perm, role.KeyPermission...)
return &resp, nil
}

View File

@ -325,10 +325,6 @@ func ctlV3PutFailAuthDisabled(cx ctlCtx, key, val string) error {
return spawnWithExpect(append(cx.PrefixArgs(), "put", key, val), "authentication is not enabled")
}
func ctlV3GetFailPerm(cx ctlCtx, key string) error {
return spawnWithExpect(append(cx.PrefixArgs(), "get", key), "permission denied")
}
func authSetupTestUser(cx ctlCtx) {
if err := ctlV3User(cx, []string{"add", "test-user", "--interactive=false"}, "User test-user created", []string{"pass"}); err != nil {
cx.t.Fatal(err)

View File

@ -15,7 +15,6 @@
package v3rpc
import (
"strings"
"sync"
"time"
@ -95,14 +94,6 @@ func newStreamInterceptor(s *etcdserver.EtcdServer) grpc.StreamServerInterceptor
}
}
func splitMethodName(fullMethodName string) (string, string) {
fullMethodName = strings.TrimPrefix(fullMethodName, "/") // remove leading slash
if i := strings.Index(fullMethodName, "/"); i >= 0 {
return fullMethodName[:i], fullMethodName[i+1:]
}
return "unknown", "unknown"
}
type serverStreamWithCtx struct {
grpc.ServerStream
ctx context.Context

View File

@ -717,7 +717,7 @@ func testV3WatchMultipleEventsTxn(t *testing.T, startRev int64) {
if err := wStream.Send(wreq); err != nil {
t.Fatalf("wStream.Send error: %v", err)
}
if resp, err := wStream.Recv(); err != nil || resp.Created == false {
if resp, err := wStream.Recv(); err != nil || !resp.Created {
t.Fatalf("create response failed: resp=%v, err=%v", resp, err)
}

View File

@ -25,8 +25,6 @@ import (
// watchBroadcast broadcasts a server watcher to many client watchers.
type watchBroadcast struct {
// wbs is the backpointer to all broadcasts on this range
wbs *watchBroadcasts
// cancel stops the underlying etcd server watcher and closes ch.
cancel context.CancelFunc
donec chan struct{}

View File

@ -1321,10 +1321,6 @@ func TestRecvMsgVote(t *testing.T) {
testRecvMsgVote(t, pb.MsgVote)
}
func testRecvMsgPreVote(t *testing.T) {
testRecvMsgVote(t, pb.MsgPreVote)
}
func testRecvMsgVote(t *testing.T, msgType pb.MessageType) {
tests := []struct {
state StateType
@ -2925,12 +2921,6 @@ func TestTransferNonMember(t *testing.T) {
}
}
// ents creates a raft state machine with a sequence of log entries at
// the given terms.
func ents(terms ...uint64) *raft {
return entsWithConfig(nil, terms...)
}
func entsWithConfig(configFunc func(*Config), terms ...uint64) *raft {
storage := NewMemoryStorage()
for i, term := range terms {

View File

@ -128,7 +128,7 @@ func TestRawNodeReadIndex(t *testing.T) {
rawNode.raft.readStates = wrs
// ensure the ReadStates can be read out
hasReady := rawNode.HasReady()
if hasReady != true {
if !hasReady {
t.Errorf("HasReady() returns %t, want %t", hasReady, true)
}
rd := rawNode.Ready()

14
test
View File

@ -19,10 +19,6 @@ if [ -z "$PASSES" ]; then
PASSES="fmt dep compile build unit"
fi
# TODO: 'client' pkg fails with gosimple from generated files
# TODO: 'rafttest' is failing with unused
GOSIMPLE_UNUSED_PATHS=$(go list ./... | sed -e 's/github.com\/coreos\/etcd\///g' | grep -vE 'cmd|vendor|rafttest|github.com/coreos/etcd$|client$')
# Invoke ./cover for HTML output
COVER=${COVER:-"-cover"}
@ -33,6 +29,10 @@ TEST_PKGS=`find . -name \*_test.go | while read a; do dirname $a; done | sort |
FORMATTABLE=`find . -name \*.go | while read a; do echo $(dirname $a)/"*.go"; done | sort | uniq | egrep -v "$IGNORE_PKGS" | sed "s|\./||g"`
TESTABLE_AND_FORMATTABLE=`echo "$TEST_PKGS" | egrep -v "$INTEGRATION_PKGS"`
# TODO: 'client' pkg fails with gosimple from generated files
# TODO: 'rafttest' is failing with unused
GOSIMPLE_UNUSED_PATHS=`find . -name \*.go | while read a; do dirname $a; done | sort | uniq | egrep -v "$IGNORE_PKGS" | grep -v 'client'`
if [ -z "$GOARCH" ]; then
GOARCH=$(go env GOARCH);
fi
@ -178,7 +178,7 @@ function fmt_pass {
if which gosimple >/dev/null; then
echo "Checking gosimple..."
for path in $GOSIMPLE_UNUSED_PATHS; do
simplResult=`gosimple $REPO_PATH/${path} || true`
simplResult=`gosimple ${path} 2>&1 || true`
if [ -n "${simplResult}" ]; then
echo -e "gosimple checking ${path} failed:\n${simplResult}"
exit 255
@ -187,11 +187,11 @@ function fmt_pass {
else
echo "Skipping gosimple..."
fi
if which unused >/dev/null; then
echo "Checking unused..."
for path in $GOSIMPLE_UNUSED_PATHS; do
unusedResult=`unused $REPO_PATH/${path} || true`
unusedResult=`unused ${path} 2>&1 || true`
if [ -n "${unusedResult}" ]; then
echo -e "unused checking ${path} failed:\n${unusedResult}"
exit 255

View File

@ -49,9 +49,6 @@ var (
var (
iterateBucketName string
iterateBucketLimit uint64
revertCopyPath string
revertRevision int64
)
func init() {

View File

@ -44,7 +44,7 @@ func main() {
fmt.Println("got --use-root=true but not root user")
os.Exit(1)
}
if *useRoot == false {
if !*useRoot {
fmt.Println("root permissions disabled, agent will not modify network")
}

View File

@ -42,7 +42,6 @@ type keyStresser struct {
rateLimiter *rate.Limiter
mu sync.Mutex
wg sync.WaitGroup
cancel func()

View File

@ -41,7 +41,6 @@ type v2Stresser struct {
wg sync.WaitGroup
mu sync.Mutex
atomicModifiedKey int64
cancel func()