Skip to content

Commit

Permalink
*: fix ineffassign lint
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Fu <fuweid89@gmail.com>
  • Loading branch information
fuweid committed Sep 18, 2023
1 parent fb8a315 commit 62e5ffb
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 18 deletions.
11 changes: 1 addition & 10 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -410,17 +410,8 @@ function unconvert_pass {
run_for_modules generic_checker run_go_tool "github.com/mdempsky/unconvert" unconvert -v
}

function ineffassign_per_package {
# bash 3.x compatible replacement of: mapfile -t gofiles < <(go_srcs_in_module)
local gofiles=()
while IFS= read -r line; do gofiles+=("$line"); done < <(go_srcs_in_module)

# TODO: ineffassign should work with package instead of files
run_go_tool github.com/gordonklaus/ineffassign "${gofiles[@]}"
}

function ineffassign_pass {
run_for_modules generic_checker ineffassign_per_package
run_for_modules generic_checker run_go_tool "github.com/gordonklaus/ineffassign"
}

function nakedret_pass {
Expand Down
4 changes: 0 additions & 4 deletions server/lease/lessor_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func benchmarkLessorGrant(benchSize int, b *testing.B) {
b.StopTimer()
if tearDown != nil {
tearDown()
tearDown = nil
}
le, tearDown = setUp(b)
b.StartTimer()
Expand All @@ -117,7 +116,6 @@ func benchmarkLessorRevoke(benchSize int, b *testing.B) {
b.StopTimer()
if tearDown != nil {
tearDown()
tearDown = nil
}
le, tearDown = setUp(b)
for j := 1; j <= benchSize; j++ {
Expand Down Expand Up @@ -148,7 +146,6 @@ func benchmarkLessorRenew(benchSize int, b *testing.B) {
b.StopTimer()
if tearDown != nil {
tearDown()
tearDown = nil
}
le, tearDown = setUp(b)
for j := 1; j <= benchSize; j++ {
Expand Down Expand Up @@ -181,7 +178,6 @@ func benchmarkLessorFindExpired(benchSize int, b *testing.B) {
b.StopTimer()
if tearDown != nil {
tearDown()
tearDown = nil
}
le, tearDown = setUp(b)
for j := 1; j <= benchSize; j++ {
Expand Down
2 changes: 1 addition & 1 deletion tests/common/compact_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestCompact(t *testing.T) {
t.Fatalf("compactTest: Compact error (%v)", err)
}

get, err = cc.Get(ctx, "key", config.GetOptions{Revision: 3})
_, err = cc.Get(ctx, "key", config.GetOptions{Revision: 3})
if err != nil {
if !strings.Contains(err.Error(), "required revision has been compacted") {
t.Fatalf("compactTest: Get compact key error (%v)", err)
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/corrupt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ func TestCompactHashCheckDetectCorruptionInterrupt(t *testing.T) {

t.Log("compaction started...")
_, err = cc.Compact(ctx, 5, config.CompactOption{})
require.NoError(t, err)

err = epc.Procs[slowCompactionNodeIndex].Close()
require.NoError(t, err)
Expand All @@ -333,6 +334,7 @@ func TestCompactHashCheckDetectCorruptionInterrupt(t *testing.T) {

t.Logf("restart proc %d to interrupt its compaction...", slowCompactionNodeIndex)
err = epc.Procs[slowCompactionNodeIndex].Restart(ctx)
require.NoError(t, err)

// Wait until the node finished compaction and the leader finished compaction hash check
_, err = epc.Procs[slowCompactionNodeIndex].Logs().ExpectWithContext(ctx, expect.ExpectedResponse{Value: "finished scheduled compaction"})
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/ctl_v3_member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func memberListSerializableTest(cx ctlCtx) {
require.NoError(cx.t, err)

resp, err = getMemberList(cx, true)
require.NoError(cx.t, err)
require.Equal(cx.t, 2, len(resp.Members))
}

Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/v3_curl_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ func testCurlV3ClusterOperations(cx ctlCtx) {
// update member
cx.t.Logf("Update peerURL from %q to %q for member %q", peerURL, updatedPeerURL, newMemberIDStr)
newMemberID, err := strconv.ParseUint(newMemberIDStr, 10, 64)
require.NoError(cx.t, err)

updateMemberReq, err := json.Marshal(&pb.MemberUpdateRequest{ID: newMemberID, PeerURLs: []string{updatedPeerURL}})
require.NoError(cx.t, err)

Expand Down
2 changes: 1 addition & 1 deletion tests/framework/e2e/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ func (cfg *EtcdProcessClusterConfig) EtcdServerProcessConfig(tb testing.TB, i in

name := fmt.Sprintf("%s-test-%d", testNameCleanRegex.ReplaceAllString(tb.Name(), ""), i)

dataDirPath := cfg.DataDirPath
var dataDirPath string
if cfg.DataDirPath == "" {
dataDirPath = tb.TempDir()
} else {
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/v3_auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,12 @@ func TestV3AuthWatchAndTokenExpire(t *testing.T) {
// The first watch gets a valid auth token through watcher.newWatcherGrpcStream()
// We should discard the first one by waiting TTL after the first watch.
wChan := c.Watch(ctx, "key", clientv3.WithRev(1))
watchResponse := <-wChan
<-wChan

time.Sleep(5 * time.Second)

wChan = c.Watch(ctx, "key", clientv3.WithRev(1))
watchResponse = <-wChan
watchResponse := <-wChan
testutil.AssertNil(t, watchResponse.Err())
}

Expand Down

0 comments on commit 62e5ffb

Please sign in to comment.