streamdal/go-sdk

View on GitHub

Showing 33 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (s *Streamdal) pauseTailHandler(_ context.Context, cmd *protos.Command) error {
          if err := validate.TailRequestPauseCommand(cmd); err != nil {
              return errors.Wrap(err, "invalid tail request pause command")
          }
      
      
      Severity: Major
      Found in tail.go and 1 other location - About 3 hrs to fix
      tail.go on lines 378..407

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 258.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (s *Streamdal) resumeTailHandler(_ context.Context, cmd *protos.Command) error {
          if err := validate.TailRequestResumeCommand(cmd); err != nil {
              return errors.Wrap(err, "invalid tail request resume command")
          }
      
      
      Severity: Major
      Found in tail.go and 1 other location - About 3 hrs to fix
      tail.go on lines 347..376

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 258.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          func TailRequestStopCommand(cmd *protos.Command) error {
              if cmd == nil {
                  return ErrNilInput
              }
          
          
          Severity: Major
          Found in validate/validate.go and 3 other locations - About 1 hr to fix
          validate/validate.go on lines 78..102
          validate/validate.go on lines 130..154
          validate/validate.go on lines 156..180

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 157.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          func TailRequestResumeCommand(cmd *protos.Command) error {
              if cmd == nil {
                  return ErrNilInput
              }
          
          
          Severity: Major
          Found in validate/validate.go and 3 other locations - About 1 hr to fix
          validate/validate.go on lines 78..102
          validate/validate.go on lines 104..128
          validate/validate.go on lines 130..154

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 157.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          func TailRequestPauseCommand(cmd *protos.Command) error {
              if cmd == nil {
                  return ErrNilInput
              }
          
          
          Severity: Major
          Found in validate/validate.go and 3 other locations - About 1 hr to fix
          validate/validate.go on lines 78..102
          validate/validate.go on lines 104..128
          validate/validate.go on lines 156..180

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 157.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

          func TailRequestStartCommand(cmd *protos.Command) error {
              if cmd == nil {
                  return ErrNilInput
              }
          
          
          Severity: Major
          Found in validate/validate.go and 3 other locations - About 1 hr to fix
          validate/validate.go on lines 104..128
          validate/validate.go on lines 130..154
          validate/validate.go on lines 156..180

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 157.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          func (s *Streamdal) setPausedTail(tail *Tail) {
              s.pausedTailsMtx.Lock()
              defer s.pausedTailsMtx.Unlock()
          
              tr := tail.Request.GetTail().Request
          Severity: Major
          Found in tail.go and 1 other location - About 1 hr to fix
          tail.go on lines 317..330

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 153.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          func (s *Streamdal) setActiveTail(tail *Tail) {
              s.tailsMtx.Lock()
              defer s.tailsMtx.Unlock()
          
              tr := tail.Request.GetTail().Request
          Severity: Major
          Found in tail.go and 1 other location - About 1 hr to fix
          tail.go on lines 332..345

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 153.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          func (s *Streamdal) removePausedTail(aud *protos.Audience, tailID string) {
              s.pausedTailsMtx.Lock()
              defer s.pausedTailsMtx.Unlock()
          
              audStr := audToStr(aud)
          Severity: Major
          Found in tail.go and 1 other location - About 1 hr to fix
          tail.go on lines 283..298

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 146.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          func (s *Streamdal) removeActiveTail(aud *protos.Audience, tailID string) {
              s.tailsMtx.Lock()
              defer s.tailsMtx.Unlock()
          
              audStr := audToStr(aud)
          Severity: Major
          Found in tail.go and 1 other location - About 1 hr to fix
          tail.go on lines 300..315

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 146.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          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
                  Severity
                  Category
                  Status
                  Source
                  Language