rueian/rueidis

View on GitHub
sentinel.go

Summary

Maintainability
B
6 hrs
Test Coverage
A
100%

sentinelClient has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

type sentinelClient struct {
    mConn     atomic.Value
    sConn     conn
    mOpt      *ClientOption
    sOpt      *ClientOption
Severity: Minor
Found in sentinel.go - About 2 hrs to fix

    Method sentinelClient.listWatch has 69 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (c *sentinelClient) listWatch(cc conn) (target string, sentinels []string, err error) {
        ctx := context.Background()
        sentinelsCMD := c.cmd.SentinelSentinels().Master(c.mOpt.Sentinel.MasterSet).Build()
        getMasterCMD := c.cmd.SentinelGetMasterAddrByName().Master(c.mOpt.Sentinel.MasterSet).Build()
        replicasCMD := c.cmd.SentinelReplicas().Master(c.mOpt.Sentinel.MasterSet).Build()
    Severity: Minor
    Found in sentinel.go - About 1 hr to fix

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

      func (c *sentinelClient) _refresh() (err error) {
          var target string
          var sentinels []string
      
          c.mu.Lock()
      Severity: Minor
      Found in sentinel.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 sentinelClient._switchTarget has 6 return statements (exceeds 4 allowed).
      Open

      func (c *sentinelClient) _switchTarget(addr string) (err error) {
          var target conn
          if atomic.LoadUint32(&c.stop) == 1 {
              return nil
          }
      Severity: Major
      Found in sentinel.go - About 40 mins to fix

        Method sentinelClient.listWatch has 5 return statements (exceeds 4 allowed).
        Open

        func (c *sentinelClient) listWatch(cc conn) (target string, sentinels []string, err error) {
            ctx := context.Background()
            sentinelsCMD := c.cmd.SentinelSentinels().Master(c.mOpt.Sentinel.MasterSet).Build()
            getMasterCMD := c.cmd.SentinelGetMasterAddrByName().Master(c.mOpt.Sentinel.MasterSet).Build()
            replicasCMD := c.cmd.SentinelReplicas().Master(c.mOpt.Sentinel.MasterSet).Build()
        Severity: Major
        Found in sentinel.go - About 35 mins to fix

          There are no issues that match your filters.

          Category
          Status