LLKennedy/httpgrpc

View on GitHub

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 {
Severity: Minor
Found in client/src/websocket/websocket.ts - About 55 mins to fix

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)
Severity: Minor
Found in proxy/streamclient.go - About 55 mins to fix

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) {
Severity: Major
Found in mercury.go - About 50 mins to fix

    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) {
    Severity: Major
    Found in convert/unary.go - About 50 mins to fix

      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
              }
      Severity: Major
      Found in proxy/proxyunary.go - About 50 mins to fix

        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) {
        Severity: Minor
        Found in internal/codegen/run.go - About 45 mins to fix

          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,
          Severity: Major
          Found in convert/stream.go - About 45 mins to fix

            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)
            Severity: Major
            Found in proxy/streamclient.go - About 45 mins to fix

              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)
              Severity: Minor
              Found in proxy/proxyunary.go - About 45 mins to fix

              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()
              Severity: Major
              Found in proxy/args.go - About 40 mins to fix

                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) {
                Severity: Minor
                Found in internal/codegen/run.go - About 35 mins to fix

                  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)
                  Severity: Major
                  Found in proxy/methods.go - About 35 mins to fix

                    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)
                    Severity: Major
                    Found in proxy/streamserver.go - About 35 mins to fix

                      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)
                      Severity: Major
                      Found in proxy/streamdual.go - About 35 mins to fix

                        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
                                }
                        Severity: Major
                        Found in proxy/proxystream.go - About 35 mins to fix

                          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
                          Severity: Minor
                          Found in proxy/args.go - About 25 mins to fix

                          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 = "[]"
                              }
                          Severity: Minor
                          Found in internal/codegen/run.go - About 25 mins to fix

                          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

                          Severity
                          Category
                          Status
                          Source
                          Language