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

Fix revive identified linter issues: var-declaration, indent-error-flow, increment-decrement, superfluous-else #7528

Merged
merged 7 commits into from
Aug 23, 2024
13 changes: 7 additions & 6 deletions cmd/protoc-gen-go-grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,11 @@ func clientStreamInterface(g *protogen.GeneratedFile, method *protogen.Method) s
typeParam := g.QualifiedGoIdent(method.Input.GoIdent) + ", " + g.QualifiedGoIdent(method.Output.GoIdent)
if method.Desc.IsStreamingClient() && method.Desc.IsStreamingServer() {
return g.QualifiedGoIdent(grpcPackage.Ident("BidiStreamingClient")) + "[" + typeParam + "]"
} else if method.Desc.IsStreamingClient() {
}
if method.Desc.IsStreamingClient() {
return g.QualifiedGoIdent(grpcPackage.Ident("ClientStreamingClient")) + "[" + typeParam + "]"
} else { // i.e. if method.Desc.IsStreamingServer()
return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingClient")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"
}
return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingClient")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"
}

func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method, index int) {
Expand Down Expand Up @@ -514,11 +514,12 @@ func serverStreamInterface(g *protogen.GeneratedFile, method *protogen.Method) s
typeParam := g.QualifiedGoIdent(method.Input.GoIdent) + ", " + g.QualifiedGoIdent(method.Output.GoIdent)
if method.Desc.IsStreamingClient() && method.Desc.IsStreamingServer() {
return g.QualifiedGoIdent(grpcPackage.Ident("BidiStreamingServer")) + "[" + typeParam + "]"
} else if method.Desc.IsStreamingClient() {
}
if method.Desc.IsStreamingClient() {
return g.QualifiedGoIdent(grpcPackage.Ident("ClientStreamingServer")) + "[" + typeParam + "]"
} else { // i.e. if method.Desc.IsStreamingServer()
return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingServer")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"
}

return g.QualifiedGoIdent(grpcPackage.Ident("ServerStreamingServer")) + "[" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"
}

func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method, hnameFuncNameFormatter func(string) string) string {
Expand Down
2 changes: 1 addition & 1 deletion examples/features/flow_control/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

var addr = flag.String("addr", "localhost:50052", "the address to connect to")

var payload string = string(make([]byte, 8*1024)) // 8KB
var payload = string(make([]byte, 8*1024)) // 8KB

func main() {
flag.Parse()
Expand Down
2 changes: 1 addition & 1 deletion examples/features/flow_control/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (

var port = flag.Int("port", 50052, "port number")

var payload string = string(make([]byte, 8*1024)) // 8KB
var payload = string(make([]byte, 8*1024)) // 8KB

// server is used to implement EchoServer.
type server struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/channelz/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (
// outside this package except by tests.
IDGen IDGenerator

db *channelMap = newChannelMap()
db = newChannelMap()
// EntriesPerPage defines the number of channelz entries to be shown on a web page.
EntriesPerPage = 50
curState int32
Expand Down
4 changes: 2 additions & 2 deletions internal/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ var (

// GRPCResolverSchemeExtraMetadata determines when gRPC will add extra
// metadata to RPCs.
GRPCResolverSchemeExtraMetadata string = "xds"
GRPCResolverSchemeExtraMetadata = "xds"

// EnterIdleModeForTesting gets the ClientConn to enter IDLE mode.
EnterIdleModeForTesting any // func(*grpc.ClientConn)
Expand All @@ -203,7 +203,7 @@ var (

// UserSetDefaultScheme is set to true if the user has overridden the
// default resolver scheme.
UserSetDefaultScheme bool = false
UserSetDefaultScheme = false

// ShuffleAddressListForTesting pseudo-randomizes the order of addresses. n
// is the number of elements. swap swaps the elements with indexes i and j.
Expand Down
7 changes: 3 additions & 4 deletions internal/transport/http2_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1642,11 +1642,10 @@ func (t *http2Client) reader(errCh chan<- error) {
t.closeStream(s, status.Error(code, msg), true, http2.ErrCodeProtocol, status.New(code, msg), nil, false)
}
continue
} else {
// Transport error.
t.Close(connectionErrorf(true, err, "error reading from server: %v", err))
return
}
// Transport error.
t.Close(connectionErrorf(true, err, "error reading from server: %v", err))
return
}
switch frame := frame.(type) {
case *http2.MetaHeadersFrame:
Expand Down
2 changes: 1 addition & 1 deletion internal/transport/http_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ type framer struct {
fr *http2.Framer
}

var writeBufferPoolMap map[int]*sync.Pool = make(map[int]*sync.Pool)
var writeBufferPoolMap = make(map[int]*sync.Pool)
var writeBufferMutex sync.Mutex

func newFramer(conn net.Conn, writeBufferSize, readBufferSize int, sharedWriteBuffer bool, maxHeaderListSize uint32) *framer {
Expand Down
6 changes: 3 additions & 3 deletions profiling/cmd/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@

if *flagEnableProfiling || *flagDisableProfiling {
return setEnabled(ctx, c, *flagEnableProfiling)
} else if *flagRetrieveSnapshot {
}
if *flagRetrieveSnapshot {

Check warning on line 94 in profiling/cmd/remote.go

View check run for this annotation

Codecov / codecov/patch

profiling/cmd/remote.go#L94

Added line #L94 was not covered by tests
return retrieveSnapshot(ctx, c, *flagSnapshot)
} else {
return fmt.Errorf("what should I do with the remote target?")
}
return fmt.Errorf("what should I do with the remote target?")

Check warning on line 97 in profiling/cmd/remote.go

View check run for this annotation

Codecov / codecov/patch

profiling/cmd/remote.go#L97

Added line #L97 was not covered by tests
}
4 changes: 2 additions & 2 deletions stats/opentelemetry/internal/testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ func createBucketCounts(recordingPoints []float64, bounds []float64) []uint64 {
continue
}
for recordingPoints[recordingPointIndex] <= bound {
bucketCount += 1
recordingPointIndex += 1
bucketCount++
recordingPointIndex++
if recordingPointIndex >= len(recordingPoints) {
break
}
Expand Down
Loading