netdata/netdata

View on GitHub
src/go/collectors/go.d.plugin/agent/module/job.go

Summary

Maintainability
C
7 hrs
Test Coverage

File job.go has 536 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// SPDX-License-Identifier: GPL-3.0-or-later

package module

import (
Severity: Minor
Found in src/go/collectors/go.d.plugin/agent/module/job.go - About 2 hrs to fix

    Job has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type Job struct {
        pluginName string
        name       string
        moduleName string
        fullName   string
    Severity: Minor
    Found in src/go/collectors/go.d.plugin/agent/module/job.go - About 2 hrs to fix

      Method Job.createChart has 63 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (j *Job) createChart(chart *Chart) {
          defer func() { chart.created = true }()
          if chart.ignore {
              return
          }
      Severity: Minor
      Found in src/go/collectors/go.d.plugin/agent/module/job.go - About 1 hr to fix

        Method Job.updateChart has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
        Open

        func (j *Job) updateChart(chart *Chart, collected map[string]int64, sinceLastRun int) bool {
            if chart.ignore {
                dims := chart.Dims[:0]
                for _, dim := range chart.Dims {
                    if !dim.remove {
        Severity: Minor
        Found in src/go/collectors/go.d.plugin/agent/module/job.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 Job.processMetrics has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
        Open

        func (j *Job) processMetrics(metrics map[string]int64, startTime time.Time, sinceLastRun int) bool {
            if !vnodes.Disabled {
                if !j.vnodeCreated && j.vnodeGUID != "" {
                    _ = j.api.HOSTINFO(j.vnodeGUID, j.vnodeHostname, j.vnodeLabels)
                    j.vnodeCreated = true
        Severity: Minor
        Found in src/go/collectors/go.d.plugin/agent/module/job.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