Skip to content

Commit

Permalink
Merge pull request #18713 from mmorel-35/whitespace
Browse files Browse the repository at this point in the history
fix: enable gofmt and whitespace linters
  • Loading branch information
ahrtr authored Oct 11, 2024
2 parents e67407b + 33d7f2d commit ab1e6ae
Show file tree
Hide file tree
Showing 59 changed files with 196 additions and 268 deletions.
1 change: 0 additions & 1 deletion client/internal/v2/keys_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func benchmarkResponseUnmarshalling(b *testing.B, children, size int) {
if newResponse, err = unmarshalSuccessfulKeysResponse(header, body); err != nil {
b.Errorf("error unmarshalling response (%v)", err)
}

}
if !reflect.DeepEqual(response.Node, newResponse.Node) {
b.Errorf("Unexpected difference in a parsed response: \n%+v\n%+v", response, newResponse)
Expand Down
1 change: 0 additions & 1 deletion client/pkg/types/set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ func driveSetTests(t *testing.T, s Set) {
} {
if tt.got != tt.want {
t.Fatalf("case %d: want %t, got %t", i, tt.want, tt.got)

}
}

Expand Down
2 changes: 0 additions & 2 deletions client/v3/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,9 +434,7 @@ func TestClientRejectOldCluster(t *testing.T) {
t.Errorf("heckVersion err:%v", err)
}
})

}

}

type mockMaintenance struct {
Expand Down
1 change: 0 additions & 1 deletion client/v3/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ func (m *maintenance) Status(ctx context.Context, endpoint string) (*StatusRespo
func (m *maintenance) HashKV(ctx context.Context, endpoint string, rev int64) (*HashKVResponse, error) {
remote, cancel, err := m.dial(endpoint)
if err != nil {

return nil, ContextError(ctx, err)
}
defer cancel()
Expand Down
1 change: 0 additions & 1 deletion client/v3/retry_interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ func (s *serverStreamingRetryingStream) receiveMsgAndIndicateRetry(m any) (bool,
return false, err // return the original error for simplicity
}
return true, err

}
return isSafeRetry(s.client, err, s.callOpts), err
}
Expand Down
1 change: 0 additions & 1 deletion client/v3/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,6 @@ func (w *watchGRPCStream) dispatchEvent(pbresp *pb.WatchResponse) bool {
}

return w.unicastResponse(wr, pbresp.WatchId)

}

// broadcastResponse send a watch response to all watch substreams.
Expand Down
1 change: 0 additions & 1 deletion contrib/raftexample/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ var defaultSnapshotCount uint64 = 10000
// current), then new log entries. To shutdown, close proposeC and read errorC.
func newRaftNode(id int, peers []string, join bool, getSnapshot func() ([]byte, error), proposeC <-chan string,
confChangeC <-chan raftpb.ConfChange) (<-chan *commit, <-chan error, <-chan *snap.Snapshotter) {

commitC := make(chan *commit)
errorC := make(chan error)

Expand Down
1 change: 0 additions & 1 deletion etcdctl/ctlv3/command/printer_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,4 @@ func printMemberListWithHexJSON(r clientv3.MemberListResponse) {
}
buffer.WriteString("}")
fmt.Println(buffer.String())

}
1 change: 0 additions & 1 deletion etcdctl/ctlv3/command/watch_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ func watchInteractiveFunc(cmd *cobra.Command, osArgs []string, envKey, envRange
fmt.Fprintf(os.Stderr, "Invalid command %s (only support watch)\n", l)
continue
}

}
}

Expand Down
1 change: 0 additions & 1 deletion pkg/adt/interval_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ func (ivt *intervalTree) Insert(ivl Interval, val any) {
func (ivt *intervalTree) insertFixup(z *intervalNode) {
for z.parent.color(ivt.sentinel) == red {
if z.parent == z.parent.parent.left { // line 3-15

y := z.parent.parent.right
if y.color(ivt.sentinel) == red {
y.c = black
Expand Down
1 change: 0 additions & 1 deletion pkg/expect/expect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ func TestResponseMatchRegularExpr(t *testing.T) {
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {

ep, err := NewExpect("echo", "-n", tc.mockOutput)
require.NoError(t, err)

Expand Down
1 change: 0 additions & 1 deletion pkg/netutil/routes_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ func getIfaceAddr(idx uint32, family uint8) (*syscall.NetlinkMessage, error) {
}

return nil, fmt.Errorf("could not find address for interface index %v", idx)

}

// Used to get a name of interface.
Expand Down
2 changes: 0 additions & 2 deletions server/auth/jwt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ func testJWTInfo(t *testing.T, opts map[string]string) {
if !errors.Is(aerr, ErrVerifyOnly) {
t.Fatalf("unexpected error when attempting to sign with public key: %v", aerr)
}

})
}
}
Expand Down Expand Up @@ -221,7 +220,6 @@ func TestJWTTokenWithMissingFields(t *testing.T) {
}

func TestJWTBad(t *testing.T) {

var badCases = map[string]map[string]string{
"no options": {},
"invalid method": {
Expand Down
2 changes: 0 additions & 2 deletions server/auth/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,6 @@ func (as *authStore) RoleDelete(r *pb.AuthRoleDeleteRequest) (*pb.AuthRoleDelete
}

tx.UnsafePutUser(updatedUser)

}

as.commitRevision(tx)
Expand Down Expand Up @@ -1114,7 +1113,6 @@ func decomposeOpts(lg *zap.Logger, optstr string) (string, map[string]string, er
}

return tokenType, typeSpecificOpts, nil

}

// NewTokenProvider creates a new token provider.
Expand Down
4 changes: 0 additions & 4 deletions server/auth/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func TestUserAdd(t *testing.T) {

if _, ok := as.rangePermCache[userName]; !ok {
t.Fatalf("user %s should be added but it doesn't exist in rangePermCache", userName)

}
}

Expand Down Expand Up @@ -270,7 +269,6 @@ func TestUserDelete(t *testing.T) {

if _, ok := as.rangePermCache[userName]; ok {
t.Fatalf("user %s should be deleted but it exists in rangePermCache", userName)

}
}

Expand Down Expand Up @@ -306,7 +304,6 @@ func TestUserDeleteAndPermCache(t *testing.T) {

if _, ok := as.rangePermCache[newUser]; !ok {
t.Fatalf("user %s should exist but it doesn't exist in rangePermCache", deletedUserName)

}
}

Expand Down Expand Up @@ -458,7 +455,6 @@ func TestIsOpPermitted(t *testing.T) {
if err := as.isOpPermitted("foo", as.Revision(), perm.Key, perm.RangeEnd, perm.PermType); !errors.Is(err, ErrPermissionDenied) {
t.Fatal(err)
}

}

func TestGetUser(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion server/embed/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ func TestInferLocalAddr(t *testing.T) {
require.Equal(t, tt.expectedLocalAddr, cfg.InferLocalAddr())
})
}

}

func (s *securityConfig) equals(t *transport.TLSInfo) bool {
Expand Down
1 change: 0 additions & 1 deletion server/etcdserver/api/membership/storev2.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func mustDeleteMemberFromStore(lg *zap.Logger, s v2store.Store, id types.ID) {
}

func mustAddToRemovedMembersInStore(lg *zap.Logger, s v2store.Store, id types.ID) {

if _, err := s.Create(RemovedMemberStoreKey(id), false, "", false, v2store.TTLOptionSet{ExpireTime: v2store.Permanent}); err != nil {
lg.Panic(
"failed to create removedMember",
Expand Down
1 change: 0 additions & 1 deletion server/etcdserver/api/v2discovery/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func TestNewProxyFunc(t *testing.T) {
if g.String() != w {
t.Errorf("%s: proxyURL=%q, want %q", in, g, w)
}

}
}

Expand Down
1 change: 0 additions & 1 deletion server/etcdserver/api/v2error/error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ func TestErrorWriteTo(t *testing.T) {
t.Errorf("HTTP headers %v, want %v", rr.HeaderMap, wheader)
}
}

}
1 change: 0 additions & 1 deletion server/etcdserver/api/v2stats/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ func (q *statsQueue) Insert(p *RequestStats) {

q.items[q.back] = p
q.totalReqSize += q.items[q.back].Size

}

// Rate function returns the package rate and byte rate
Expand Down
1 change: 0 additions & 1 deletion server/etcdserver/api/v2store/event_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,4 @@ func (eh *EventHistory) clone() *EventHistory {
Queue: clonedQueue,
LastIndex: eh.LastIndex,
}

}
2 changes: 0 additions & 2 deletions server/etcdserver/api/v2store/event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
// Add 200 events into that queue, and test if the
// previous 100 events have been swapped out.
func TestEventQueue(t *testing.T) {

eh := newEventHistory(100)

// Add
Expand Down Expand Up @@ -114,7 +113,6 @@ func TestEventIndexHistoryCleared(t *testing.T) {
// Add 1000 events into that queue, and test if scanning
// works still for previous events.
func TestFullEventQueue(t *testing.T) {

eh := newEventHistory(10)

// Add
Expand Down
3 changes: 0 additions & 3 deletions server/etcdserver/api/v2store/heap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func TestHeapPushPop(t *testing.T) {
}
min = node.ExpireTime
}

}

func TestHeapUpdate(t *testing.T) {
Expand Down Expand Up @@ -88,7 +87,5 @@ func TestHeapUpdate(t *testing.T) {
t.Fatal("heap sort wrong!")
}
}

}

}
1 change: 0 additions & 1 deletion server/etcdserver/api/v2store/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ func (n *node) Repr(recursive, sorted bool, clock clockwork.Clock) *NodeExtern {
i := 0

for _, child := range children {

if child.IsHidden() { // get will not list hidden node
continue
}
Expand Down
1 change: 0 additions & 1 deletion server/etcdserver/api/v2store/node_extern.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func (eNode *NodeExtern) loadInternalNode(n *node, recursive, sorted bool, clock
if sorted {
sort.Sort(eNode.Nodes)
}

} else { // node is a file
value, _ := n.Read()
eNode.Value = &value
Expand Down
5 changes: 0 additions & 5 deletions server/etcdserver/api/v2store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ func getCompareFailCause(n *node, which int, prevValue string, prevIndex uint64)

func (s *store) CompareAndSwap(nodePath string, prevValue string, prevIndex uint64,
value string, expireOpts TTLOptionSet) (*Event, error) {

var err *v2error.Error

s.worldLock.Lock()
Expand Down Expand Up @@ -565,7 +564,6 @@ func (s *store) Update(nodePath string, newValue string, expireOpts TTLOptionSet

func (s *store) internalCreate(nodePath string, dir bool, value string, unique, replace bool,
expireTime time.Time, action string) (*Event, *v2error.Error) {

currIndex, nextIndex := s.CurrentIndex, s.CurrentIndex+1

if unique { // append unique item under the node path
Expand Down Expand Up @@ -624,7 +622,6 @@ func (s *store) internalCreate(nodePath string, dir bool, value string, unique,
eNode.Value = &valueCopy

n = newKV(s, nodePath, value, nextIndex, d, expireTime)

} else { // create directory
eNode.Dir = true

Expand Down Expand Up @@ -653,7 +650,6 @@ func (s *store) internalGet(nodePath string) (*node, *v2error.Error) {
nodePath = path.Clean(path.Join("/", nodePath))

walkFunc := func(parent *node, name string) (*node, *v2error.Error) {

if !parent.IsDir() {
err := v2error.NewError(v2error.EcodeNotDir, parent.Path, s.CurrentIndex)
return nil, err
Expand Down Expand Up @@ -707,7 +703,6 @@ func (s *store) DeleteExpiredKeys(cutoff time.Time) {

s.WatcherHub.notify(e)
}

}

// checkDir will check whether the component is a directory under parent node.
Expand Down
1 change: 0 additions & 1 deletion server/etcdserver/api/v2store/store_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ func BenchmarkWatchWithSetBatch(b *testing.B) {
for i := 0; i < b.N; i++ {
<-watchers[i].EventChan()
}

}

func BenchmarkWatchOneKey(b *testing.B) {
Expand Down
1 change: 0 additions & 1 deletion server/etcdserver/api/v2store/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,4 @@ func TestWatcher(t *testing.T) {
if e != re {
t.Fatal("recv != send")
}

}
1 change: 0 additions & 1 deletion server/etcdserver/api/v3rpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func Server(s *etcdserver.EtcdServer, tls *tls.Config, interceptor grpc.UnarySer
if s.Cfg.ExperimentalEnableDistributedTracing {
chainUnaryInterceptors = append(chainUnaryInterceptors, otelgrpc.UnaryServerInterceptor(s.Cfg.ExperimentalTracerOptions...))
chainStreamInterceptors = append(chainStreamInterceptors, otelgrpc.StreamServerInterceptor(s.Cfg.ExperimentalTracerOptions...))

}

opts = append(opts, grpc.ChainUnaryInterceptor(chainUnaryInterceptors...))
Expand Down
2 changes: 0 additions & 2 deletions server/etcdserver/apply/apply_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ func TestAuthApplierV3_Apply(t *testing.T) {
require.Equalf(t, result, tc.expectResult, "Apply: got %v, expect: %v", result, tc.expectResult)
})
}

}

// TestAuthApplierV3_AdminPermission ensures the admin permission is checked for certain
Expand Down Expand Up @@ -823,5 +822,4 @@ func TestCheckLeasePutsKeys(t *testing.T) {

aa.authInfo = auth.AuthInfo{Username: "bob", Revision: aa.as.Revision()}
assert.NoError(t, aa.checkLeasePutsKeys(l), "bob should be able to access key 'a'")

}
3 changes: 0 additions & 3 deletions server/etcdserver/cindex/cindex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (

// TestConsistentIndex ensures that LoadConsistentIndex/Save/ConsistentIndex and backend.BatchTx can work well together.
func TestConsistentIndex(t *testing.T) {

be, tmpPath := betesting.NewTmpBackend(t, time.Microsecond, 10)
ci := NewConsistentIndex(be)

Expand Down Expand Up @@ -133,7 +132,6 @@ func TestConsistentIndexDecrease(t *testing.T) {
}

func TestFakeConsistentIndex(t *testing.T) {

r := rand.Uint64()
ci := NewFakeConsistentIndex(r)
index := ci.ConsistentIndex()
Expand All @@ -146,5 +144,4 @@ func TestFakeConsistentIndex(t *testing.T) {
if index != r {
t.Errorf("expected %d,got %d", r, index)
}

}
1 change: 0 additions & 1 deletion server/storage/backend/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ func TestLockVerify(t *testing.T) {
defer revertVerifyFunc()
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {

be, _ := betesting.NewTmpBackend(t, time.Hour, 10000)
be.SetTxPostLockInsideApplyHook(tc.txPostLockInsideApplyHook)

Expand Down
Loading

0 comments on commit ab1e6ae

Please sign in to comment.