ipfs/ipfs-cluster

View on GitHub
monitor/pubsubmon/pubsubmon.go

Summary

Maintainability
A
3 hrs
Test Coverage

Method Monitor.logFromPubsub has a Cognitive Complexity of 27 (exceeds 15 allowed). Consider refactoring.
Open

func (mon *Monitor) logFromPubsub() {
    ctx, span := trace.StartSpan(mon.ctx, "monitor/pubsub/logFromPubsub")
    defer span.End()

    decodeWarningPrinted := false
Severity: Minor
Found in monitor/pubsubmon/pubsubmon.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

Avoid deeply nested control flow statements.
Open

                    if !decodeWarningPrinted {
                        logger.Warning("Peers in versions <= v0.13.3 detected. These peers will not receive metrics from this or other newer peers. Please upgrade them.")
                        decodeWarningPrinted = true
                    }
Severity: Major
Found in monitor/pubsubmon/pubsubmon.go - About 45 mins to fix

    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

      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

      There are no issues that match your filters.

      Category
      Status