Skip to content

Commit

Permalink
Fix revive identified linter issues: var-declaration, indent-error-fl…
Browse files Browse the repository at this point in the history
…ow, increment-decrement, superfluous-else (grpc#7528)

* Fixed linter issues for superfluous-else, increment-decrement, indent-error-flow, var-declaration

* Reverting context-as-argument in server.go

* Revert "Optimising the code by fixing var-declaration, indent-error-flow, increment-decrement, superfluous-else"

* Optimising the code by fixing var-declaration, indent-error-flow, increment-decrement, superfluous-else

* dummy commit for re-trigger
  • Loading branch information
janardhanvissa authored Aug 23, 2024
1 parent e4b09f1 commit 3d95421
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
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 @@ -1667,11 +1667,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 @@ -393,7 +393,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 @@ func remoteCommand() error {

if *flagEnableProfiling || *flagDisableProfiling {
return setEnabled(ctx, c, *flagEnableProfiling)
} else if *flagRetrieveSnapshot {
}
if *flagRetrieveSnapshot {
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?")
}
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

0 comments on commit 3d95421

Please sign in to comment.