rueian/rueidis

View on GitHub
pipe.go

Summary

Maintainability
F
1 wk
Test Coverage
A
99%

File pipe.go has 1393 lines of code (exceeds 500 allowed). Consider refactoring.
Wontfix

package rueidis

import (
    "bufio"
    "context"
Severity: Major
Found in pipe.go - About 2 days to fix

    Function _newPipe has a Cognitive Complexity of 100 (exceeds 20 allowed). Consider refactoring.
    Open

    func _newPipe(connFn func() (net.Conn, error), option *ClientOption, r2ps, nobg bool) (p *pipe, err error) {
        conn, err := connFn()
        if err != nil {
            return nil, err
        }
    Severity: Minor
    Found in pipe.go - About 1 day 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 pipe._backgroundRead has a Cognitive Complexity of 88 (exceeds 20 allowed). Consider refactoring.
    Wontfix

    func (p *pipe) _backgroundRead() (err error) {
        var (
            msg   RedisMessage
            cond  *sync.Cond
            ones  = make([]Completed, 1)
    Severity: Minor
    Found in pipe.go - About 1 day 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 pipe.DoMulti has a Cognitive Complexity of 60 (exceeds 20 allowed). Consider refactoring.
    Wontfix

    func (p *pipe) DoMulti(ctx context.Context, multi ...Completed) *redisresults {
        resp := resultsp.Get(len(multi), len(multi))
        if err := ctx.Err(); err != nil {
            for i := 0; i < len(resp.s); i++ {
                resp.s[i] = newErrResult(err)
    Severity: Minor
    Found in pipe.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

    Function _newPipe has 182 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func _newPipe(connFn func() (net.Conn, error), option *ClientOption, r2ps, nobg bool) (p *pipe, err error) {
        conn, err := connFn()
        if err != nil {
            return nil, err
        }
    Severity: Major
    Found in pipe.go - About 6 hrs to fix

      Method pipe.DoMultiCache has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
      Open

      func (p *pipe) DoMultiCache(ctx context.Context, multi ...CacheableTTL) *redisresults {
          if p.cache == nil {
              commands := make([]Completed, len(multi))
              for i, ct := range multi {
                  commands[i] = Completed(ct.Cmd)
      Severity: Minor
      Found in pipe.go - About 4 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 pipe._backgroundWrite has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring.
      Open

      func (p *pipe) _backgroundWrite() (err error) {
          var (
              ones  = make([]Completed, 1)
              multi []Completed
              ch    chan RedisResult
      Severity: Minor
      Found in pipe.go - About 4 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 pipe._backgroundRead has 122 lines of code (exceeds 50 allowed). Consider refactoring.
      Wontfix

      func (p *pipe) _backgroundRead() (err error) {
          var (
              msg   RedisMessage
              cond  *sync.Cond
              ones  = make([]Completed, 1)
      Severity: Major
      Found in pipe.go - About 3 hrs to fix

        Method pipe.doCacheMGet has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring.
        Open

        func (p *pipe) doCacheMGet(ctx context.Context, cmd Cacheable, ttl time.Duration) RedisResult {
            commands := cmd.Commands()
            keys := len(commands) - 1
            builder := cmds.NewBuilder(cmds.InitSlot)
            result := RedisResult{val: RedisMessage{typ: '*', values: nil}}
        Severity: Minor
        Found in pipe.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

        Method pipe.Do has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
        Wontfix

        func (p *pipe) Do(ctx context.Context, cmd Completed) (resp RedisResult) {
            if err := ctx.Err(); err != nil {
                return newErrResult(err)
            }
        
        
        Severity: Minor
        Found in pipe.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

        Method pipe.DoMulti has 97 lines of code (exceeds 50 allowed). Consider refactoring.
        Wontfix

        func (p *pipe) DoMulti(ctx context.Context, multi ...Completed) *redisresults {
            resp := resultsp.Get(len(multi), len(multi))
            if err := ctx.Err(); err != nil {
                for i := 0; i < len(resp.s); i++ {
                    resp.s[i] = newErrResult(err)
        Severity: Major
        Found in pipe.go - About 2 hrs to fix

          pipe has 25 methods (exceeds 20 allowed). Consider refactoring.
          Open

          type pipe struct {
              conn            net.Conn
              error           atomic.Value
              clhks           atomic.Value // closed hook, invoked after the conn is closed
              pshks           atomic.Value // pubsub hook, registered by the SetPubSubHooks
          Severity: Minor
          Found in pipe.go - About 2 hrs to fix

            Method pipe.doCacheMGet has 92 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (p *pipe) doCacheMGet(ctx context.Context, cmd Cacheable, ttl time.Duration) RedisResult {
                commands := cmd.Commands()
                keys := len(commands) - 1
                builder := cmds.NewBuilder(cmds.InitSlot)
                result := RedisResult{val: RedisMessage{typ: '*', values: nil}}
            Severity: Major
            Found in pipe.go - About 2 hrs to fix

              Method pipe.DoMultiStream has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
              Open

              func (p *pipe) DoMultiStream(ctx context.Context, pool *pool, multi ...Completed) MultiRedisResultStream {
                  for _, cmd := range multi {
                      cmds.CompletedCS(cmd).Verify()
                  }
              
              
              Severity: Minor
              Found in pipe.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

              Method pipe.DoMultiCache has 78 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (p *pipe) DoMultiCache(ctx context.Context, multi ...CacheableTTL) *redisresults {
                  if p.cache == nil {
                      commands := make([]Completed, len(multi))
                      for i, ct := range multi {
                          commands[i] = Completed(ct.Cmd)
              Severity: Major
              Found in pipe.go - About 2 hrs to fix

                Method pipe.syncDoMulti has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
                Open

                func (p *pipe) syncDoMulti(dl time.Time, dlOk bool, resp []RedisResult, multi []Completed) {
                    if dlOk {
                        if p.timeout > 0 {
                            defaultDeadline := time.Now().Add(p.timeout)
                            if dl.After(defaultDeadline) {
                Severity: Minor
                Found in pipe.go - About 1 hr 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 pipe.Do has 65 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (p *pipe) Do(ctx context.Context, cmd Completed) (resp RedisResult) {
                    if err := ctx.Err(); err != nil {
                        return newErrResult(err)
                    }
                
                
                Severity: Minor
                Found in pipe.go - About 1 hr to fix

                  Method pipe.handlePush has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (p *pipe) handlePush(values []RedisMessage) (reply bool, unsubscribe bool) {
                      if len(values) < 2 {
                          return
                      }
                      // TODO: handle other push data
                  Severity: Minor
                  Found in pipe.go - About 1 hr 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 pipe.handlePush has 62 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func (p *pipe) handlePush(values []RedisMessage) (reply bool, unsubscribe bool) {
                      if len(values) < 2 {
                          return
                      }
                      // TODO: handle other push data
                  Severity: Minor
                  Found in pipe.go - About 1 hr to fix

                    Method pipe.Receive has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
                    Wontfix

                    func (p *pipe) Receive(ctx context.Context, subscribe Completed, fn func(message PubSubMessage)) error {
                        if p.nsubs == nil || p.psubs == nil || p.ssubs == nil {
                            return p.Error()
                        }
                    
                    
                    Severity: Minor
                    Found in pipe.go - About 1 hr 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 pipe._background has 55 lines of code (exceeds 50 allowed). Consider refactoring.
                    Wontfix

                    func (p *pipe) _background() {
                        p.conn.SetDeadline(time.Time{})
                        go func() {
                            p._exit(p._backgroundWrite())
                            close(p.close)
                    Severity: Minor
                    Found in pipe.go - About 1 hr to fix

                      Method pipe.DoMultiStream has 52 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (p *pipe) DoMultiStream(ctx context.Context, pool *pool, multi ...Completed) MultiRedisResultStream {
                          for _, cmd := range multi {
                              cmds.CompletedCS(cmd).Verify()
                          }
                      
                      
                      Severity: Minor
                      Found in pipe.go - About 1 hr to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            if !blocked {
                                                time.Sleep(flushDelay - time.Since(flushStart)) // ref: https://github.com/redis/rueidis/issues/156
                                            }
                        Severity: Major
                        Found in pipe.go - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              goto next
                          Severity: Major
                          Found in pipe.go - About 45 mins to fix

                            Function _newPipe has 7 return statements (exceeds 4 allowed).
                            Open

                            func _newPipe(connFn func() (net.Conn, error), option *ClientOption, r2ps, nobg bool) (p *pipe, err error) {
                                conn, err := connFn()
                                if err != nil {
                                    return nil, err
                                }
                            Severity: Major
                            Found in pipe.go - About 45 mins to fix

                              Method pipe.DoMulti has 7 return statements (exceeds 4 allowed).
                              Open

                              func (p *pipe) DoMulti(ctx context.Context, multi ...Completed) *redisresults {
                                  resp := resultsp.Get(len(multi), len(multi))
                                  if err := ctx.Err(); err != nil {
                                      for i := 0; i < len(resp.s); i++ {
                                          resp.s[i] = newErrResult(err)
                              Severity: Major
                              Found in pipe.go - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if pttl := msg.values[i].integer; pttl >= 0 {
                                                        cp.setExpireAt(now.Add(time.Duration(pttl) * time.Millisecond).UnixMilli())
                                                    }
                                Severity: Major
                                Found in pipe.go - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                  if msg.values[i], err = readNextMessage(p.r); err != nil {
                                                      return
                                                  }
                                  Severity: Major
                                  Found in pipe.go - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                        } else if strings.Contains(re.string, "CLIENT") {
                                                            err = fmt.Errorf("%s: %w", re.string, ErrNoCache)
                                                        } else if r2 {
                                                            continue
                                                        }
                                    Severity: Major
                                    Found in pipe.go - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                          goto process
                                      Severity: Major
                                      Found in pipe.go - About 45 mins to fix

                                        Avoid deeply nested control flow statements.
                                        Open

                                                        if pttl := msg.values[ci-1].integer; pttl >= 0 {
                                                            cp.setExpireAt(now.Add(time.Duration(pttl) * time.Millisecond).UnixMilli())
                                                        }
                                        Severity: Major
                                        Found in pipe.go - About 45 mins to fix

                                          Avoid deeply nested control flow statements.
                                          Open

                                                              if _, ok := err.(*RedisError); ok {
                                                                  err = ErrDoCacheAborted
                                                              }
                                          Severity: Major
                                          Found in pipe.go - About 45 mins to fix

                                            Avoid deeply nested control flow statements.
                                            Open

                                                                for i := 0; i < len(multi) && !blocked; i++ {
                                                                    blocked = blocked || multi[i].IsBlock()
                                                                }
                                            Severity: Major
                                            Found in pipe.go - About 45 mins to fix

                                              Avoid deeply nested control flow statements.
                                              Open

                                                                  if i != j {
                                                                      msg.values[i] = v
                                                                  }
                                              Severity: Major
                                              Found in pipe.go - About 45 mins to fix

                                                Method pipe.handlePush has 6 return statements (exceeds 4 allowed).
                                                Open

                                                func (p *pipe) handlePush(values []RedisMessage) (reply bool, unsubscribe bool) {
                                                    if len(values) < 2 {
                                                        return
                                                    }
                                                    // TODO: handle other push data
                                                Severity: Major
                                                Found in pipe.go - About 40 mins to fix

                                                  Method pipe.DoCache has 6 return statements (exceeds 4 allowed).
                                                  Wontfix

                                                  func (p *pipe) DoCache(ctx context.Context, cmd Cacheable, ttl time.Duration) RedisResult {
                                                      if p.cache == nil {
                                                          return p.Do(ctx, Completed(cmd))
                                                      }
                                                  
                                                  
                                                  Severity: Major
                                                  Found in pipe.go - About 40 mins to fix

                                                    Method pipe.Do has 5 return statements (exceeds 4 allowed).
                                                    Open

                                                    func (p *pipe) Do(ctx context.Context, cmd Completed) (resp RedisResult) {
                                                        if err := ctx.Err(); err != nil {
                                                            return newErrResult(err)
                                                        }
                                                    
                                                    
                                                    Severity: Major
                                                    Found in pipe.go - About 35 mins to fix

                                                      Method pipe.Receive has 5 return statements (exceeds 4 allowed).
                                                      Open

                                                      func (p *pipe) Receive(ctx context.Context, subscribe Completed, fn func(message PubSubMessage)) error {
                                                          if p.nsubs == nil || p.psubs == nil || p.ssubs == nil {
                                                              return p.Error()
                                                          }
                                                      
                                                      
                                                      Severity: Major
                                                      Found in pipe.go - About 35 mins to fix

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

                                                                if ok {
                                                                    if p.timeout > 0 {
                                                                        defaultDeadline := time.Now().Add(p.timeout)
                                                                        if dl.After(defaultDeadline) {
                                                                            dl = defaultDeadline
                                                        Severity: Major
                                                        Found in pipe.go and 1 other location - About 2 hrs to fix
                                                        pipe.go on lines 1183..1201

                                                        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 195.

                                                        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

                                                            if dlOk {
                                                                if p.timeout > 0 {
                                                                    defaultDeadline := time.Now().Add(p.timeout)
                                                                    if dl.After(defaultDeadline) {
                                                                        dl = defaultDeadline
                                                        Severity: Major
                                                        Found in pipe.go and 1 other location - About 2 hrs to fix
                                                        pipe.go on lines 1114..1132

                                                        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 195.

                                                        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

                                                            if dlOk {
                                                                if p.timeout > 0 {
                                                                    defaultDeadline := time.Now().Add(p.timeout)
                                                                    if dl.After(defaultDeadline) {
                                                                        dl = defaultDeadline
                                                        Severity: Major
                                                        Found in pipe.go and 1 other location - About 1 hr to fix
                                                        pipe.go on lines 1064..1076

                                                        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 161.

                                                        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

                                                                if ok {
                                                                    if p.timeout > 0 {
                                                                        defaultDeadline := time.Now().Add(p.timeout)
                                                                        if dl.After(defaultDeadline) {
                                                                            dl = defaultDeadline
                                                        Severity: Major
                                                        Found in pipe.go and 1 other location - About 1 hr to fix
                                                        pipe.go on lines 1152..1164

                                                        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 161.

                                                        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 3 locations. Consider refactoring.
                                                        Open

                                                            case "punsubscribe":
                                                                p.psubs.Unsubscribe(values[1].string)
                                                                if len(values) >= 3 {
                                                                    p.pshks.Load().(*pshks).hooks.OnSubscription(PubSubSubscription{Kind: values[0].string, Channel: values[1].string, Count: values[2].integer})
                                                                }
                                                        Severity: Major
                                                        Found in pipe.go and 2 other locations - About 50 mins to fix
                                                        pipe.go on lines 668..673
                                                        pipe.go on lines 680..685

                                                        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 118.

                                                        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 3 locations. Consider refactoring.
                                                        Open

                                                            case "unsubscribe":
                                                                p.nsubs.Unsubscribe(values[1].string)
                                                                if len(values) >= 3 {
                                                                    p.pshks.Load().(*pshks).hooks.OnSubscription(PubSubSubscription{Kind: values[0].string, Channel: values[1].string, Count: values[2].integer})
                                                                }
                                                        Severity: Major
                                                        Found in pipe.go and 2 other locations - About 50 mins to fix
                                                        pipe.go on lines 674..679
                                                        pipe.go on lines 680..685

                                                        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 118.

                                                        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 3 locations. Consider refactoring.
                                                        Open

                                                            case "sunsubscribe":
                                                                p.ssubs.Unsubscribe(values[1].string)
                                                                if len(values) >= 3 {
                                                                    p.pshks.Load().(*pshks).hooks.OnSubscription(PubSubSubscription{Kind: values[0].string, Channel: values[1].string, Count: values[2].integer})
                                                                }
                                                        Severity: Major
                                                        Found in pipe.go and 2 other locations - About 50 mins to fix
                                                        pipe.go on lines 668..673
                                                        pipe.go on lines 674..679

                                                        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 118.

                                                        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

                                                            case "message":
                                                                if len(values) >= 3 {
                                                                    m := PubSubMessage{Channel: values[1].string, Message: values[2].string}
                                                                    p.nsubs.Publish(values[1].string, m)
                                                                    p.pshks.Load().(*pshks).hooks.OnMessage(m)
                                                        Severity: Minor
                                                        Found in pipe.go and 1 other location - About 35 mins to fix
                                                        pipe.go on lines 662..667

                                                        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 107.

                                                        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

                                                            case "smessage":
                                                                if len(values) >= 3 {
                                                                    m := PubSubMessage{Channel: values[1].string, Message: values[2].string}
                                                                    p.ssubs.Publish(values[1].string, m)
                                                                    p.pshks.Load().(*pshks).hooks.OnMessage(m)
                                                        Severity: Minor
                                                        Found in pipe.go and 1 other location - About 35 mins to fix
                                                        pipe.go on lines 650..655

                                                        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 107.

                                                        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

                                                        There are no issues that match your filters.

                                                        Category
                                                        Status