LLKennedy/httpgrpc

View on GitHub

Showing 37 of 125 total issues

File service.pb.go has 872 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
//     protoc-gen-go v1.25.0
//     protoc        v3.10.1
// source: service.proto
Severity: Major
Found in internal/testservice/service/service.pb.go - About 1 day to fix

    Function file_service_proto_init has 168 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func file_service_proto_init() {
        if File_service_proto != nil {
            return
        }
        if !protoimpl.UnsafeEnabled {
    Severity: Major
    Found in internal/testservice/service/service.pb.go - About 5 hrs to fix

      File proxy.pb.go has 619 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      // Code generated by protoc-gen-go. DO NOT EDIT.
      // versions:
      //     protoc-gen-go v1.25.0
      //     protoc        v3.10.1
      // source: proxy.proto
      Severity: Minor
      Found in httpapi/proxy.pb.go - About 4 hrs to fix

        File service_grpc.pb.go has 582 lines of code (exceeds 500 allowed). Consider refactoring.
        Open

        // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
        
        package service
        
        import (
        Severity: Minor
        Found in internal/testservice/service/service_grpc.pb.go - About 4 hrs to fix

          File websocket.ts has 306 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { ProtoJSONCompatible, Parser } from "@llkennedy/protoc-gen-tsjson";
          import { IMutex, Mutex } from "../common";
          import * as uuid from "uuid";
          
          export const EOFMessage = "EOF";
          Severity: Minor
          Found in client/src/websocket/websocket.ts - About 3 hrs to fix

            Function file_service_proto_init has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
            Open

            func file_service_proto_init() {
                if File_service_proto != nil {
                    return
                }
                if !protoimpl.UnsafeEnabled {
            Severity: Minor
            Found in internal/testservice/service/service.pb.go - About 3 hrs 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 file_proxy_proto_init has 100 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func file_proxy_proto_init() {
                if File_proxy_proto != nil {
                    return
                }
                if !protoimpl.UnsafeEnabled {
            Severity: Major
            Found in httpapi/proxy.pb.go - About 3 hrs to fix

              Function initConnection has 63 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private async initConnection(): Promise<EstablishedWebsocket<ReqT, ResT>> {
                      if (this.initialised) {
                          throw new Error("cannot initialise MercuryWebSocket twice");
                      }
                      this.initialised = true;
              Severity: Major
              Found in client/src/websocket/websocket.ts - About 2 hrs to fix

                MercuryWebSocket has 22 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export class MercuryWebSocket<ReqT extends ProtoJSONCompatible, ResT = any> {
                    //#region properties
                    /** The logger used for all logs from this class */
                    public readonly logger: Logger = console;
                    /** The name of this websocket */
                Severity: Minor
                Found in client/src/websocket/websocket.ts - About 2 hrs to fix

                  Method Server.handleClientStream has 73 lines of code (exceeds 50 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 1 hr to fix

                    Function makeMockedWebsocket has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    async function makeMockedWebsocket(sandbox: sinon.SinonSandbox): Promise<mockedWebsocket> {
                        let fake = new FakeWebsocket();
                        let evStub = sandbox.stub(fake, "addEventListener");
                        let done: ((a: any) => any)[] = [];
                        let wait: [Promise<(ev: CloseEvent) => void>, Promise<(ev: Event) => void>, Promise<(ev: MessageEvent) => void>, Promise<(ev: Event) => void>] = [
                    Severity: Minor
                    Found in client/src/websocket/websocket.spec.ts - About 1 hr to fix

                      Method Server.handleServerStream has 63 lines of code (exceeds 50 allowed). Consider refactoring.
                      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: Minor
                      Found in proxy/streamserver.go - About 1 hr to fix

                        Method stream.Serve has 61 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (h stream) Serve(c *websocket.Conn) {
                            errWriter := errorWriter{
                                c:       c,
                                loggers: h.loggers,
                                txid:    h.txid,
                        Severity: Minor
                        Found in convert/stream.go - About 1 hr to fix

                          Method Server.handleDualStream has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                          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: Minor
                          Found in proxy/streamdual.go - About 1 hr to fix

                            Method Server.callStructStruct has 57 lines of code (exceeds 50 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 1 hr to fix

                              Function ProxyRequest has 56 lines of code (exceeds 50 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) {
                                  remote := httpapi.NewExposedServiceClient(conn)
                                  isWebsocket := false
                                  upgradeHader, ok := r.Header["Upgrade"]
                                  if ok {
                              Severity: Minor
                              Found in convert/unary.go - About 1 hr to fix

                                Function feed has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                export async function feed() {
                                    let ws = new MercuryWebSocket<FeedData, FeedResponse>("ws://127.0.0.1:4848/Feed", FeedResponse.Parse, "FeedSocket", console);
                                    await ws.init()
                                    let stream = new ClientStream(ws);
                                    let data1 = new FeedData();
                                Severity: Minor
                                Found in internal/testservice/client/src/feed.ts - About 1 hr to fix

                                  Function getNativeTypeName has 55 lines of code (exceeds 50 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 1 hr to fix

                                    Function initConnection has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        private async initConnection(): Promise<EstablishedWebsocket<ReqT, ResT>> {
                                            if (this.initialised) {
                                                throw new Error("cannot initialise MercuryWebSocket twice");
                                            }
                                            this.initialised = true;
                                    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

                                    Function generateImportsForMethod has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                                    Open

                                    func generateImportsForMethod(f *descriptorpb.MethodDescriptorProto, ownPkg string, fileName string, importMap map[string][]string, content *strings.Builder, impexp importsExports) (useGoogle bool) {
                                        for _, typeName := range []string{f.GetInputType(), f.GetOutputType()} {
                                            if typeName == "" {
                                                continue
                                            }
                                    Severity: Minor
                                    Found in internal/codegen/run.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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language