ipfs/ipfs-cluster

View on GitHub

Showing 105 of 124 total issues

Avoid deeply nested control flow statements.
Open

                    if err != nil {
                        logger.Error(err)
                        continue
                    }
Severity: Major
Found in monitor/pubsubmon/pubsubmon.go - About 45 mins to fix

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

    func (rw *raftWrapper) WaitForPeer(ctx context.Context, pid string, depart bool) error {
        ctx, span := trace.StartSpan(ctx, "consensus/raft/WaitForPeer")
        defer span.End()
    
        for {
    Severity: Minor
    Found in consensus/raft/raft.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 PinOptions.Equals has 12 return statements (exceeds 10 allowed).
    Open

    func (po PinOptions) Equals(po2 PinOptions) bool {
        if po.Name != po2.Name {
            return false
        }
    
    
    Severity: Major
    Found in api/types.go - About 40 mins to fix

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

      func NewAPIWithHost(ctx context.Context, cfg *Config, h host.Host) (*API, error) {
          api := API{
              config: cfg,
          }
          capi, err := common.NewAPIWithHost(ctx, &cfg.Config, h, api.routes)
      Severity: Minor
      Found in api/rest/restapi.go and 1 other location - About 35 mins to fix
      api/pinsvcapi/pinsvcapi.go on lines 132..139

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

      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

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

      func NewAPIWithHost(ctx context.Context, cfg *Config, h host.Host) (*API, error) {
          api := API{
              config: cfg,
          }
          capi, err := common.NewAPIWithHost(ctx, &cfg.Config, h, api.routes)
      Severity: Minor
      Found in api/pinsvcapi/pinsvcapi.go and 1 other location - About 35 mins to fix
      api/rest/restapi.go on lines 54..61

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

      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 Cluster.filterMetrics has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring.
      Open

      func (c *Cluster) filterMetrics(ctx context.Context, mSet api.MetricsSet, numMetrics int, currentAllocs, priorityList, blacklist []peer.ID) classifiedMetrics {
          curPeersMap := make(map[peer.ID][]api.Metric)
          candPeersMap := make(map[peer.ID][]api.Metric)
          prioPeersMap := make(map[peer.ID][]api.Metric)
      
      
      Severity: Minor
      Found in allocate.go - About 35 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 API.statusCidsHandler has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring.
      Open

      func (api *API) statusCidsHandler(w http.ResponseWriter, r *http.Request) {
          ctx, cancel := context.WithCancel(r.Context())
          defer cancel()
      
          queryValues := r.URL.Query()
      Severity: Minor
      Found in api/rest/restapi.go - About 35 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 Server.repoGCHandler has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring.
      Open

      func (proxy *Server) repoGCHandler(w http.ResponseWriter, r *http.Request) {
          queryValues := r.URL.Query()
          streamErrors := queryValues.Get("stream-errors") == "true"
          // ignoring `quiet` since it only affects text output
      
      
      Severity: Minor
      Found in api/ipfsproxy/ipfsproxy.go - About 35 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 partitionedMetric.chooseNext has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring.
      Open

      func (pnedm *partitionedMetric) chooseNext() peer.ID {
          lenp := len(pnedm.partitions)
          if lenp == 0 {
              return ""
          }
      Severity: Minor
      Found in allocator/balanced/balanced.go - About 35 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 Pin.ProtoUnmarshal has a Cognitive Complexity of 17 (exceeds 15 allowed). Consider refactoring.
      Open

      func (pin *Pin) ProtoUnmarshal(data []byte) error {
          pbPin := pb.Pin{}
          err := proto.Unmarshal(data, &pbPin)
          if err != nil {
              return err
      Severity: Minor
      Found in api/types.go - About 35 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 API.SendResponse has a Cognitive Complexity of 16 (exceeds 15 allowed). Consider refactoring.
      Open

      func (api *API) SendResponse(
          w http.ResponseWriter,
          status int,
          err error,
          resp interface{},
      Severity: Minor
      Found in api/common/api.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

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

      func (adder *Adder) AddAllAndPin(file files.Node) (ipld.Node, error) {
          if err := adder.addFileNode("", file, true); err != nil {
              return nil, err
          }
      
      
      Severity: Minor
      Found in adder/ipfsadd/add.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

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

      func (spt *Tracker) opWorker(pinF func(*optracker.Operation) error, prioCh, normalCh chan *optracker.Operation) {
      
          var op *optracker.Operation
      
          for {
      Severity: Minor
      Found in pintracker/stateless/stateless.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

      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

      Your code does not pass gofmt in 2 places. Go fmt your code!
      Open

      // Package balanced implements an allocator that can sort allocations
      Severity: Minor
      Found in allocator/balanced/balanced.go by gofmt

      Your code does not pass gofmt in 1 place. Go fmt your code!
      Open

      // Package pubsubmon implements a PeerMonitor component for IPFS Cluster that
      Severity: Minor
      Found in monitor/pubsubmon/pubsubmon.go by gofmt

      exported method API.HealthHandler should have comment or be unexported
      Open

      func (api *API) HealthHandler(w http.ResponseWriter, r *http.Request) {
      Severity: Minor
      Found in api/common/api.go by golint

      Your code does not pass gofmt in 1 place. Go fmt your code!
      Open

      package pinsvcapi
      Severity: Minor
      Found in api/pinsvcapi/pinsvcapi_test.go by gofmt

      Your code does not pass gofmt in 1 place. Go fmt your code!
      Open

      // Package sharding implements a sharding ClusterDAGService places
      Severity: Minor
      Found in adder/sharding/dag_service.go by gofmt

      Your code does not pass gofmt in 1 place. Go fmt your code!
      Open

      // Package cmdutils contains utilities to facilitate building of command line
      Severity: Minor
      Found in cmdutils/cmdutils.go by gofmt
      Severity
      Category
      Status
      Source
      Language