streamdal/go-sdk

View on GitHub

Showing 23 of 36 total issues

Method Streamdal.Process has a Cognitive Complexity of 59 (exceeds 20 allowed). Consider refactoring.
Open

func (s *Streamdal) Process(ctx context.Context, req *ProcessRequest) *ProcessResponse {
    resp := &ProcessResponse{
        PipelineStatus: make([]*protos.PipelineStatus, 0),
        Metadata:       make(map[string]string),
    }
Severity: Minor
Found in go_sdk.go - About 6 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

Method Streamdal.Process has 178 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (s *Streamdal) Process(ctx context.Context, req *ProcessRequest) *ProcessResponse {
    resp := &ProcessResponse{
        PipelineStatus: make([]*protos.PipelineStatus, 0),
        Metadata:       make(map[string]string),
    }
Severity: Major
Found in go_sdk.go - About 6 hrs to fix

    File go_sdk.go has 648 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    // Package streamdal is a library that allows running of Client data pipelines against data
    // This package is designed to be included in golang message bus libraries. The only public
    // method is Process() which is used to run pipelines against data.
    //
    // Use of this package requires a running instance of a streamdal server©.
    Severity: Minor
    Found in go_sdk.go - About 5 hrs to fix

      Method Streamdal.register has 93 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (s *Streamdal) register(looper director.Looper) error {
          req := &protos.RegisterRequest{
              ServiceName: s.config.ServiceName,
              SessionId:   s.sessionID,
              ClientInfo:  s.genClientInfo(),
      Severity: Major
      Found in register.go - About 2 hrs to fix

        Method Streamdal.register has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
        Open

        func (s *Streamdal) register(looper director.Looper) error {
            req := &protos.RegisterRequest{
                ServiceName: s.config.ServiceName,
                SessionId:   s.sessionID,
                ClientInfo:  s.genClientInfo(),
        Severity: Minor
        Found in register.go - About 2 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 New has 68 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func New(cfg *Config) (*Streamdal, error) {
            if err := validateConfig(cfg); err != nil {
                return nil, errors.Wrap(err, "unable to validate config")
            }
        
        
        Severity: Minor
        Found in go_sdk.go - About 1 hr to fix

          Method Streamdal.register has 12 return statements (exceeds 4 allowed).
          Open

          func (s *Streamdal) register(looper director.Looper) error {
              req := &protos.RegisterRequest{
                  ServiceName: s.config.ServiceName,
                  SessionId:   s.sessionID,
                  ClientInfo:  s.genClientInfo(),
          Severity: Major
          Found in register.go - About 1 hr to fix

            Method function.Exec has 10 return statements (exceeds 4 allowed).
            Open

            func (f *function) Exec(ctx context.Context, req []byte) ([]byte, error) {
                ptrLen := uint64(len(req))
            
                inputPtr, err := f.alloc.Call(ctx, ptrLen)
                if err != nil {
            Severity: Major
            Found in function.go - About 1 hr to fix

              Function New has 9 return statements (exceeds 4 allowed).
              Open

              func New(cfg *Config) (*Streamdal, error) {
                  if err := validateConfig(cfg); err != nil {
                      return nil, errors.Wrap(err, "unable to validate config")
                  }
              
              
              Severity: Major
              Found in go_sdk.go - About 55 mins to fix

                Method Streamdal.handleCondition has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    ctx context.Context,
                    req *ProcessRequest,
                    resp *ProcessResponse,
                    stepCond *protos.PipelineStepConditions,
                    step *protos.PipelineStep,
                Severity: Major
                Found in go_sdk.go - About 50 mins to fix

                  Function WriteResponseToMemory has 8 return statements (exceeds 4 allowed).
                  Open

                  func WriteResponseToMemory(module api.Module, msg proto.Message) (uint64, error) {
                      if module == nil {
                          return 0, errors.New("module cannot be nil")
                      }
                  
                  
                  Severity: Major
                  Found in helper/helper.go - About 50 mins to fix

                    Method Tail.startWorker has 7 return statements (exceeds 4 allowed).
                    Open

                    func (t *Tail) startWorker(looper director.Looper, stream protos.Internal_SendTailClient) {
                        if stream == nil {
                            t.log.Error("stream is nil, unable to start tail worker")
                            return
                        }
                    Severity: Major
                    Found in tail.go - About 45 mins to fix

                      Method Streamdal.Process has 7 return statements (exceeds 4 allowed).
                      Open

                      func (s *Streamdal) Process(ctx context.Context, req *ProcessRequest) *ProcessResponse {
                          resp := &ProcessResponse{
                              PipelineStatus: make([]*protos.PipelineStatus, 0),
                              Metadata:       make(map[string]string),
                          }
                      Severity: Major
                      Found in go_sdk.go - About 45 mins to fix

                        Function Audience has 6 return statements (exceeds 4 allowed).
                        Open

                        func Audience(aud *protos.Audience) error {
                            if aud == nil {
                                return ErrNilInput
                            }
                        
                        
                        Severity: Major
                        Found in validate/validate.go - About 40 mins to fix

                          Method HostFunc.HTTPRequest has 6 return statements (exceeds 4 allowed).
                          Open

                          func (h *HostFunc) HTTPRequest(_ context.Context, module api.Module, ptr, length int32) uint64 {
                              request := &steps.HttpRequest{}
                          
                              if err := helper.ReadRequestFromMemory(module, request, ptr, length); err != nil {
                                  return httpRequestResponse(module, http.StatusInternalServerError, "unable to read HTTP request params: "+err.Error(), nil)
                          Severity: Major
                          Found in hostfunc/httprequest.go - About 40 mins to fix

                            Function TailRequestStartCommand has 6 return statements (exceeds 4 allowed).
                            Open

                            func TailRequestStartCommand(cmd *protos.Command) error {
                                if cmd == nil {
                                    return ErrNilInput
                                }
                            
                            
                            Severity: Major
                            Found in validate/validate.go - About 40 mins to fix

                              Function ReadRequestFromMemory has 6 return statements (exceeds 4 allowed).
                              Open

                              func ReadRequestFromMemory(module api.Module, msg proto.Message, ptr, length int32) error {
                                  if length <= 0 {
                                      return errors.New("length must be greater than 0")
                                  }
                              
                              
                              Severity: Major
                              Found in helper/helper.go - About 40 mins to fix

                                Function TailRequestStopCommand has 6 return statements (exceeds 4 allowed).
                                Open

                                func TailRequestStopCommand(cmd *protos.Command) error {
                                    if cmd == nil {
                                        return ErrNilInput
                                    }
                                
                                
                                Severity: Major
                                Found in validate/validate.go - About 40 mins to fix

                                  Function TailRequestPauseCommand has 6 return statements (exceeds 4 allowed).
                                  Open

                                  func TailRequestPauseCommand(cmd *protos.Command) error {
                                      if cmd == nil {
                                          return ErrNilInput
                                      }
                                  
                                  
                                  Severity: Major
                                  Found in validate/validate.go - About 40 mins to fix

                                    Function TailRequestResumeCommand has 6 return statements (exceeds 4 allowed).
                                    Open

                                    func TailRequestResumeCommand(cmd *protos.Command) error {
                                        if cmd == nil {
                                            return ErrNilInput
                                        }
                                    
                                    
                                    Severity: Major
                                    Found in validate/validate.go - About 40 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language