netdata/netdata

View on GitHub
src/go/collectors/go.d.plugin/agent/discovery/sd/pipeline/pipeline.go

Summary

Maintainability
B
4 hrs
Test Coverage

Method Pipeline.processGroup has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
Open

func (p *Pipeline) processGroup(tgg model.TargetGroup) *confgroup.Group {
    if len(tgg.Targets()) == 0 {
        if _, ok := p.configs[tgg.Source()]; !ok {
            return nil
        }

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 Pipeline.processGroup has 57 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (p *Pipeline) processGroup(tgg model.TargetGroup) *confgroup.Group {
    if len(tgg.Targets()) == 0 {
        if _, ok := p.configs[tgg.Source()]; !ok {
            return nil
        }

    Function New has 5 return statements (exceeds 4 allowed).
    Open

    func New(cfg Config) (*Pipeline, error) {
        if err := validateConfig(cfg); err != nil {
            return nil, err
        }
    
    
    Severity: Major
    Found in src/go/collectors/go.d.plugin/agent/discovery/sd/pipeline/pipeline.go - About 35 mins to fix

      Method Pipeline.registerDiscoverers has 5 return statements (exceeds 4 allowed).
      Open

      func (p *Pipeline) registerDiscoverers(conf Config) error {
          for _, cfg := range conf.Discover {
              switch cfg.Discoverer {
              case "net_listeners":
                  cfg.NetListeners.Source = conf.Source
      Severity: Major
      Found in src/go/collectors/go.d.plugin/agent/discovery/sd/pipeline/pipeline.go - About 35 mins to fix

        There are no issues that match your filters.

        Category
        Status