Showing 37 of 125 total issues
Function messageHandler
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private async messageHandler(ev: MessageEvent<any>): Promise<void> {
if (typeof ev.data === "string" && ev.data === EOFMessage) {
this.responseBuffer.push(new EOFError());
this.recvOpen = Promise.resolve(new EOFError());
} else {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Server.handleClientStream
has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring. Open
func (s *Server) handleClientStream(ctx context.Context, procType reflect.Type, caller reflect.Value, srv httpapi.ExposedService_ProxyStreamServer) (err error) {
defer func() {
r := recover()
if r != nil {
err = status.Errorf(codes.Internal, "caught panic for client stream: %v", r)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function ProxyRequest
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
func ProxyRequest(ctx context.Context, w http.ResponseWriter, r *http.Request, procedure string, conn *grpc.ClientConn, txid string, loggers ...logs.Writer) {
Function ProxyRequest
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
func ProxyRequest(ctx context.Context, w http.ResponseWriter, r *http.Request, procedure string, conn grpc.ClientConnInterface, txid string, loggers ...logs.Writer) {
Method Server.ProxyUnary
has 8 return statements (exceeds 4 allowed). Open
func (s *Server) ProxyUnary(ctx context.Context, req *httpapi.Request) (res *httpapi.Response, err error) {
wrapErr := func(code codes.Code, err error) error {
if err == nil {
return nil
}
Function generateImportsForMethod
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
func generateImportsForMethod(f *descriptorpb.MethodDescriptorProto, ownPkg string, fileName string, importMap map[string][]string, content *strings.Builder, impexp importsExports) (useGoogle bool) {
Method stream.Serve
has 7 return statements (exceeds 4 allowed). Open
func (h stream) Serve(c *websocket.Conn) {
errWriter := errorWriter{
c: c,
loggers: h.loggers,
txid: h.txid,
Method Server.handleClientStream
has 7 return statements (exceeds 4 allowed). Open
func (s *Server) handleClientStream(ctx context.Context, procType reflect.Type, caller reflect.Value, srv httpapi.ExposedService_ProxyStreamServer) (err error) {
defer func() {
r := recover()
if r != nil {
err = status.Errorf(codes.Internal, "caught panic for client stream: %v", r)
Method Server.callStructStruct
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (s *Server) callStructStruct(ctx context.Context, inputJSON []byte, procType reflect.Type, caller reflect.Value) (res *httpapi.Response, err error) {
// Create new instance of struct argument to pass into real implementation
builtRequest := reflect.New(procType.In(2).Elem())
builtRequestPtr := builtRequest.Interface()
builtRequestMessage, ok := builtRequestPtr.(proto.Message)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function validateArgs
has 6 return statements (exceeds 4 allowed). Open
func validateArgs(expected, found reflect.Type, pattern apiMethodPattern) error {
// All this to get a proper array out of these reflection types
expectedInLen := expected.NumIn()
expectedOutLen := expected.NumOut()
foundInLen := found.NumIn()
Function generateService
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func generateService(f *descriptorpb.FileDescriptorProto, service *descriptorpb.ServiceDescriptorProto, content *strings.Builder, impexp importsExports, parsedMethods map[string]parsedMethod) {
Function validateMethod
has 5 return statements (exceeds 4 allowed). Open
func validateMethod(apiMethod reflect.Method, serverType reflect.Type) (methodType string, procedureName string, pattern apiMethodPattern, err error) {
name := apiMethod.Name
httpType, trueName, valid := MatchAndStripMethodName(name)
if !valid {
err = fmt.Errorf("%s does not begin with a valid HTTP method", name)
Method Server.handleServerStream
has 5 return statements (exceeds 4 allowed). Open
func (s *Server) handleServerStream(ctx context.Context, procType reflect.Type, caller reflect.Value, srv httpapi.ExposedService_ProxyStreamServer) (err error) {
defer func() {
r := recover()
if r != nil {
err = status.Errorf(codes.Internal, "caught panic for server stream: %v", r)
Method Server.handleDualStream
has 5 return statements (exceeds 4 allowed). Open
func (s *Server) handleDualStream(ctx context.Context, procType reflect.Type, caller reflect.Value, srv httpapi.ExposedService_ProxyStreamServer) (err error) {
defer func() {
r := recover()
if r != nil {
err = status.Errorf(codes.Internal, "caught panic for dual stream: %v", r)
Method Server.ProxyStream
has 5 return statements (exceeds 4 allowed). Open
func (s *Server) ProxyStream(srv httpapi.ExposedService_ProxyStreamServer) (err error) {
wrapErr := func(code codes.Code, err error) error {
if err == nil {
return nil
}
Function getPattern
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func getPattern(args reflect.Type) (pattern apiMethodPattern) {
defer func() {
if r := recover(); r != nil {
// Panic means something wasn't expected, which means this isn't a known pattern
pattern = apiMethodPatternUnknown
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function getNativeTypeName
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func getNativeTypeName(field *descriptorpb.FieldDescriptorProto, message *descriptorpb.DescriptorProto, pkgName string, fileExports []string) string {
repeatedStr := ""
if field.GetLabel() == descriptorpb.FieldDescriptorProto_LABEL_REPEATED {
repeatedStr = "[]"
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"