netdata/netdata

View on GitHub
src/go/collectors/go.d.plugin/modules/k8s_state/charts.go

Summary

Maintainability
D
2 days
Test Coverage

File charts.go has 739 lines of code (exceeds 500 allowed). Consider refactoring.
Open

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

package k8s_state

import (
Severity: Minor
Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go - About 7 hrs to fix

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (ks *KubeState) addContainerWaitingStateReasonToChart(ps *podState, cs *containerState, reason string) {
        id := fmt.Sprintf(containersStateWaitingChartTmpl.ID, replaceDots(ps.id()), cs.name)
        c := ks.Charts().Get(id)
        if c == nil {
            ks.Warningf("chart '%s' does not exist", id)
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go and 1 other location - About 2 hrs to fix
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 749..765

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 205.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (ks *KubeState) addContainerTerminatedStateReasonToChart(ps *podState, cs *containerState, reason string) {
        id := fmt.Sprintf(containersStateTerminatedChartTmpl.ID, replaceDots(ps.id()), cs.name)
        c := ks.Charts().Get(id)
        if c == nil {
            ks.Warningf("chart '%s' does not exist", id)
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go and 1 other location - About 2 hrs to fix
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 731..747

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 205.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (ks *KubeState) newNodeCharts(ns *nodeState) *module.Charts {
        cs := nodeChartsTmpl.Copy()
        for _, c := range *cs {
            c.ID = fmt.Sprintf(c.ID, replaceDots(ns.id()))
            c.Labels = ks.newNodeChartLabels(ns)
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go and 1 other location - About 1 hr to fix
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 583..593

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 157.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (ks *KubeState) newPodCharts(ps *podState) *module.Charts {
        charts := podChartsTmpl.Copy()
        for _, c := range *charts {
            c.ID = fmt.Sprintf(c.ID, replaceDots(ps.id()))
            c.Labels = ks.newPodChartLabels(ps)
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go and 1 other location - About 1 hr to fix
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 391..401

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 157.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    var nodeChartsTmpl = module.Charts{
        nodeAllocatableCPURequestsUtilChartTmpl.Copy(),
        nodeAllocatableCPURequestsUsedChartTmpl.Copy(),
        nodeAllocatableCPULimitsUtilChartTmpl.Copy(),
        nodeAllocatableCPULimitsUsedChartTmpl.Copy(),
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go and 1 other location - About 1 hr to fix
    src/go/collectors/go.d.plugin/modules/upsd/charts.go on lines 38..62

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 154.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (ks *KubeState) removeNodeCharts(ns *nodeState) {
        prefix := fmt.Sprintf("node_%s", replaceDots(ns.id()))
        for _, c := range *ks.Charts() {
            if strings.HasPrefix(c.ID, prefix) {
                c.MarkRemove()
    Severity: Minor
    Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go and 1 other location - About 35 mins to fix
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 635..643

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 107.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        podConditionChartTmpl = module.Chart{
            IDSep:    true,
            ID:       "pod_%s.condition",
            Title:    "Condition",
            Units:    "state",
    Severity: Minor
    Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go and 1 other location - About 35 mins to fix
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 511..525

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 107.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    func (ks *KubeState) removePodCharts(ps *podState) {
        prefix := fmt.Sprintf("pod_%s", replaceDots(ps.id()))
        for _, c := range *ks.Charts() {
            if strings.HasPrefix(c.ID, prefix) {
                c.MarkRemove()
    Severity: Minor
    Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go and 1 other location - About 35 mins to fix
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 419..427

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 107.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        podPhaseChartTmpl = module.Chart{
            IDSep:    true,
            ID:       "pod_%s.phase",
            Title:    "Phase",
            Units:    "state",
    Severity: Minor
    Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go and 1 other location - About 35 mins to fix
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 496..510

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 107.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        podContainersStateChartTmpl = module.Chart{
            IDSep:    true,
            ID:       "pod_%s.containers_state",
            Title:    "Containers state",
            Units:    "containers",
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go and 3 other locations - About 35 mins to fix
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 346..360
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 361..375
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 566..580

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 104.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        nodeInitContainersStateChartTmpl = module.Chart{
            IDSep:    true,
            ID:       "node_%s.init_containers_state",
            Title:    "Init containers state",
            Units:    "containers",
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go and 3 other locations - About 35 mins to fix
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 346..360
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 551..565
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 566..580

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 104.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        podInitContainersStateChartTmpl = module.Chart{
            IDSep:    true,
            ID:       "pod_%s.init_containers_state",
            Title:    "Init containers state",
            Units:    "containers",
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go and 3 other locations - About 35 mins to fix
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 346..360
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 361..375
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 551..565

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 104.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 4 locations. Consider refactoring.
    Open

        nodeContainersStateChartTmpl = module.Chart{
            IDSep:    true,
            ID:       "node_%s.containers_state",
            Title:    "Containers state",
            Units:    "containers",
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/k8s_state/charts.go and 3 other locations - About 35 mins to fix
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 361..375
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 551..565
    src/go/collectors/go.d.plugin/modules/k8s_state/charts.go on lines 566..580

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 104.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    There are no issues that match your filters.

    Category
    Status