firehol/netdata

View on GitHub
src/go/plugin/go.d/modules/k8s_state/collect.go

Summary

Maintainability
C
7 hrs
Test Coverage

Method KubeState.collectPodsState has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
Open

func (ks *KubeState) collectPodsState(mx map[string]int64) {
    now := time.Now()
    for _, ps := range ks.state.pods {
        // Skip cronjobs (each of them is a unique container because name contains hash)
        // to avoid overwhelming Netdata with high cardinality metrics.
Severity: Minor
Found in src/go/plugin/go.d/modules/k8s_state/collect.go - About 3 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 KubeState.collectPodsState has 105 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (ks *KubeState) collectPodsState(mx map[string]int64) {
    now := time.Now()
    for _, ps := range ks.state.pods {
        // Skip cronjobs (each of them is a unique container because name contains hash)
        // to avoid overwhelming Netdata with high cardinality metrics.
Severity: Major
Found in src/go/plugin/go.d/modules/k8s_state/collect.go - About 3 hrs to fix

    Method KubeState.collectNodesState has 54 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (ks *KubeState) collectNodesState(mx map[string]int64) {
        now := time.Now()
        for _, ns := range ks.state.nodes {
            if ns.deleted {
                delete(ks.state.nodes, nodeSource(ns.name))
    Severity: Minor
    Found in src/go/plugin/go.d/modules/k8s_state/collect.go - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status