ipfs/ipfs-cluster

View on GitHub
cluster.go

Summary

Maintainability
F
6 days
Test Coverage

File cluster.go has 1596 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package ipfscluster

import (
    "context"
    "encoding/json"
Severity: Major
Found in cluster.go - About 3 days to fix

    Cluster has 59 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type Cluster struct {
        ctx    context.Context
        cancel func()
    
        id        peer.ID
    Severity: Major
    Found in cluster.go - About 1 day to fix

      Method Cluster.alertsHandler has a Cognitive Complexity of 33 (exceeds 15 allowed). Consider refactoring.
      Wontfix

      func (c *Cluster) alertsHandler() {
          for {
              select {
              case <-c.ctx.Done():
                  return
      Severity: Minor
      Found in cluster.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 Cluster.Shutdown has a Cognitive Complexity of 27 (exceeds 15 allowed). Consider refactoring.
      Open

      func (c *Cluster) Shutdown(ctx context.Context) error {
          ctx, span := trace.StartSpan(ctx, "cluster/Shutdown")
          defer span.End()
      
          c.shutdownLock.Lock()
      Severity: Minor
      Found in cluster.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 Cluster.globalPinInfoStream has a Cognitive Complexity of 25 (exceeds 15 allowed). Consider refactoring.
      Open

      func (c *Cluster) globalPinInfoStream(ctx context.Context, comp, method string, inChan interface{}, out chan<- api.GlobalPinInfo) error {
          defer close(out)
      
          ctx, span := trace.StartSpan(ctx, "cluster/globalPinInfoStream")
          defer span.End()
      Severity: Minor
      Found in cluster.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 Cluster.globalPinInfoCid has 96 lines of code (exceeds 80 allowed). Consider refactoring.
      Open

      func (c *Cluster) globalPinInfoCid(ctx context.Context, comp, method string, h api.Cid) (api.GlobalPinInfo, error) {
          ctx, span := trace.StartSpan(ctx, "cluster/globalPinInfoCid")
          defer span.End()
      
          // The object we will return
      Severity: Major
      Found in cluster.go - About 1 hr to fix

        Method Cluster.globalPinInfoStream has 95 lines of code (exceeds 80 allowed). Consider refactoring.
        Open

        func (c *Cluster) globalPinInfoStream(ctx context.Context, comp, method string, inChan interface{}, out chan<- api.GlobalPinInfo) error {
            defer close(out)
        
            ctx, span := trace.StartSpan(ctx, "cluster/globalPinInfoStream")
            defer span.End()
        Severity: Major
        Found in cluster.go - About 1 hr to fix

          Function NewCluster has 13 arguments (exceeds 6 allowed). Consider refactoring.
          Open

              ctx context.Context,
              host host.Host,
              dht *dual.DHT,
              cfg *Config,
              datastore ds.Datastore,
          Severity: Major
          Found in cluster.go - About 1 hr to fix

            Method Cluster.globalPinInfoCid has a Cognitive Complexity of 21 (exceeds 15 allowed). Consider refactoring.
            Open

            func (c *Cluster) globalPinInfoCid(ctx context.Context, comp, method string, h api.Cid) (api.GlobalPinInfo, error) {
                ctx, span := trace.StartSpan(ctx, "cluster/globalPinInfoCid")
                defer span.End()
            
                // The object we will return
            Severity: Minor
            Found in cluster.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 Cluster.Join has a Cognitive Complexity of 19 (exceeds 15 allowed). Consider refactoring.
            Open

            func (c *Cluster) Join(ctx context.Context, addr ma.Multiaddr) error {
                ctx, span := trace.StartSpan(ctx, "cluster/Join")
                defer span.End()
            
                logger.Debugf("Join(%s)", addr)
            Severity: Minor
            Found in cluster.go - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method Cluster.watchPeers has a Cognitive Complexity of 18 (exceeds 15 allowed). Consider refactoring.
            Open

            func (c *Cluster) watchPeers() {
                ticker := time.NewTicker(c.config.PeerWatchInterval)
                defer ticker.Stop()
            
                for {
            Severity: Minor
            Found in cluster.go - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Method Cluster.watchPinset has a Cognitive Complexity of 16 (exceeds 15 allowed). Consider refactoring.
            Open

            func (c *Cluster) watchPinset() {
                ctx, span := trace.StartSpan(c.ctx, "cluster/watchPinset")
                defer span.End()
            
                stateSyncTimer := time.NewTimer(c.config.StateSyncInterval)
            Severity: Minor
            Found in cluster.go - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            FIXME found
            Confirmed

                // TODO: FIXME: potentially unpinning shards which are referenced
            Severity: Minor
            Found in cluster.go by fixme

            FIXME found
            Confirmed

                    // FIXME: repinning a shard type will overwrite replication
            Severity: Minor
            Found in cluster.go by fixme

            FIXME found
            Confirmed

                    // FIXME: indirect shard pins could have max-depth 2
            Severity: Minor
            Found in cluster.go by fixme

            There are no issues that match your filters.

            Category
            Status