ipfs/ipfs-cluster

View on GitHub
ipfsconn/ipfshttp/ipfshttp.go

Summary

Maintainability
B
5 hrs
Test Coverage

File ipfshttp.go has 997 lines of code (exceeds 500 allowed). Consider refactoring.
Wontfix

// Package ipfshttp implements an IPFS Cluster IPFSConnector component. It
// uses the IPFS HTTP API to communicate to IPFS.
package ipfshttp

import (
Severity: Major
Found in ipfsconn/ipfshttp/ipfshttp.go - About 1 day to fix

    Connector has 26 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type Connector struct {
        // struct alignment! These fields must be up-front.
        updateMetricCount uint64
        ipfsPinCount      int64
    
    
    Severity: Minor
    Found in ipfsconn/ipfshttp/ipfshttp.go - About 3 hrs to fix

      Method Connector.Pin has a Cognitive Complexity of 24 (exceeds 15 allowed). Consider refactoring.
      Open

      func (ipfs *Connector) Pin(ctx context.Context, pin api.Pin) error {
          ctx, span := trace.StartSpan(ctx, "ipfsconn/ipfshttp/Pin")
          defer span.End()
      
          hash := pin.Cid
      Severity: Minor
      Found in ipfsconn/ipfshttp/ipfshttp.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 Connector.PinLs has a Cognitive Complexity of 20 (exceeds 15 allowed). Consider refactoring.
      Open

      func (ipfs *Connector) PinLs(ctx context.Context, typeFilters []string, out chan<- api.IPFSPinInfo) error {
          defer close(out)
          bodies := make([]io.ReadCloser, len(typeFilters))
      
          ctx, span := trace.StartSpan(ctx, "ipfsconn/ipfshttp/PinLs")
      Severity: Minor
      Found in ipfsconn/ipfshttp/ipfshttp.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

      There are no issues that match your filters.

      Category
      Status