ipfs/ipfs-cluster

View on GitHub
pintracker/stateless/stateless.go

Summary

Maintainability
B
4 hrs
Test Coverage

File stateless.go has 515 lines of code (exceeds 500 allowed). Consider refactoring.
Wontfix

// Package stateless implements a PinTracker component for IPFS Cluster, which
// aims to reduce the memory footprint when handling really large cluster
// states.
package stateless

Severity: Minor
Found in pintracker/stateless/stateless.go - About 2 hrs to fix

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

    func (spt *Tracker) StatusAll(ctx context.Context, filter api.TrackerStatus, out chan<- api.PinInfo) error {
        ctx, span := trace.StartSpan(ctx, "tracker/stateless/StatusAll")
        defer span.End()
    
        ipfsid := spt.getIPFSID(ctx)
    Severity: Minor
    Found in pintracker/stateless/stateless.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 Tracker.StatusAll has 97 lines of code (exceeds 80 allowed). Consider refactoring.
    Open

    func (spt *Tracker) StatusAll(ctx context.Context, filter api.TrackerStatus, out chan<- api.PinInfo) error {
        ctx, span := trace.StartSpan(ctx, "tracker/stateless/StatusAll")
        defer span.End()
    
        ipfsid := spt.getIPFSID(ctx)
    Severity: Major
    Found in pintracker/stateless/stateless.go - About 1 hr to fix

      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

      There are no issues that match your filters.

      Category
      Status