Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplifications and cleanups (gosimple) #1996

Merged
merged 4 commits into from
Apr 16, 2018
Merged

Conversation

knweiss
Copy link
Contributor

@knweiss knweiss commented Apr 15, 2018

Apply various code simplifications and cleanups found by gosimple.

One commit per category. Please see individual commit msgs for details.

This fixes:
balancer/base/balancer.go:149:2: redundant return statement (S1023)
balancer_v1_wrapper.go:260:2: redundant return statement (S1023)
balancer_v1_wrapper.go:273:2: redundant return statement (S1023)
balancer_v1_wrapper.go:285:2: redundant return statement (S1023)
benchmark/benchmark.go:68:2: redundant return statement (S1023)
clientconn.go:1461:2: redundant return statement (S1023)
grpclb.go:223:2: redundant return statement (S1023)
grpclb.go:260:2: redundant return statement (S1023)
grpclb_util.go:201:2: redundant return statement (S1023)
rpc_util.go:278:50: redundant return statement (S1023)
rpc_util.go:296:56: redundant return statement (S1023)
rpc_util.go:314:56: redundant return statement (S1023)
rpc_util.go:333:53: redundant return statement (S1023)
rpc_util.go:354:52: redundant return statement (S1023)
rpc_util.go:387:56: redundant return statement (S1023)
rpc_util.go:416:53: redundant return statement (S1023)
stream.go:651:2: redundant return statement (S1023)
@knweiss knweiss changed the title Simplifications and cleanups Simplifications and cleanups (gosimple) Apr 15, 2018
knweiss added 3 commits April 15, 2018 15:32
(I've dropped similar gosimple cleanups using time.Until() as this API is not
available in go1.6 and go1.7)
This fixes:
benchmark/worker/benchmark_client.go:151:36: should use make([]*grpc.ClientConn, connCount) instead (S1019)
benchmark/worker/benchmark_client.go:231:47: should use make([]lockingHistogram, rpcCountPerConn * len(conns)) instead (S1019)
benchmark/worker/benchmark_client.go:343:39: should use make([]*stats.Histogram, len(bc.lockingHistograms)) instead (S1019)
benchmark/worker/benchmark_client.go:369:22: should use make([]uint32, len(mergedHistogram.Buckets)) instead (S1019)
encoding/encoding.go:85:47: should use make(map[string]Codec) instead (S1019)
proxy_test.go:116:26: should use make([]byte, len(msg)) instead (S1019)
This fixes:
clientconn.go:948:3: should write m = cc.sc.Methods[method[:i+1]] instead of m, _ = cc.sc.Methods[method[:i+1]] (S1005)
encoding/proto/proto_test.go:43:5: should use !bytes.Equal(p.GetBody(), expectedBody) instead (S1004)
resolver/dns/dns_resolver.go:260:2: should merge variable declaration with assignment on next line (S1021)
resolver/dns/dns_resolver.go:344:2: should use 'return <expr>' instead of 'if <expr> { return <bool> }; return <bool>' (S1008)
@knweiss
Copy link
Contributor Author

knweiss commented Apr 15, 2018

I've removed seven additional gosimple cleanups using time.Until() as Travis failed with go1.6 and go1.7. The function is not available in these old versions.

Copy link
Member

@dfawley dfawley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanups!

@dfawley dfawley added the Type: Internal Cleanup Refactors, etc label Apr 16, 2018
@dfawley dfawley merged commit ef3a1ad into grpc:master Apr 16, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Oct 13, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants