netdata/netdata

View on GitHub
src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go

Summary

Maintainability
D
2 days
Test Coverage

Method Kubelet.collectStorageDataKeyGenerationLatencies has 52 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (k *Kubelet) collectStorageDataKeyGenerationLatencies(raw prometheus.Series, mx *metrics) {
    latencies := &mx.APIServer.Storage.DataKeyGeneration.Latencies
    metricName := "apiserver_storage_data_key_generation_latencies_microseconds_bucket"

    for _, metric := range raw.FindByName(metricName) {
Severity: Minor
Found in src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go - About 1 hr to fix

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

    func (k *Kubelet) collectRESTClientHTTPRequests(raw prometheus.Series, mx *metrics) {
        metricName := "rest_client_requests_total"
        chart := k.charts.Get("rest_client_requests_by_code")
    
        for _, metric := range raw.FindByName(metricName) {
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go and 1 other location - About 5 hrs to fix
    src/go/collectors/go.d.plugin/modules/k8s_kubeproxy/collect.go on lines 97..128

    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 376.

    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

    func (k *Kubelet) collectRuntimeOperationsErrors(raw prometheus.Series, mx *metrics) {
        chart := k.charts.Get("kubelet_runtime_operations_errors")
    
        // kubelet_runtime_operations_errors_total
        for _, metric := range raw.FindByNames("kubelet_runtime_operations_errors", "kubelet_runtime_operations_errors_total") {
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 278..294
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 314..330
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 332..348

    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 4 locations. Consider refactoring.
    Open

    func (k *Kubelet) collectRuntimeOperations(raw prometheus.Series, mx *metrics) {
        chart := k.charts.Get("kubelet_runtime_operations")
    
        // kubelet_runtime_operations_total
        for _, metric := range raw.FindByNames("kubelet_runtime_operations", "kubelet_runtime_operations_total") {
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 296..312
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 314..330
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 332..348

    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 4 locations. Consider refactoring.
    Open

    func (k *Kubelet) collectDockerOperations(raw prometheus.Series, mx *metrics) {
        chart := k.charts.Get("kubelet_docker_operations")
    
        // kubelet_docker_operations_total
        for _, metric := range raw.FindByNames("kubelet_docker_operations", "kubelet_docker_operations_total") {
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 278..294
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 296..312
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 332..348

    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 4 locations. Consider refactoring.
    Open

    func (k *Kubelet) collectDockerOperationsErrors(raw prometheus.Series, mx *metrics) {
        chart := k.charts.Get("kubelet_docker_operations_errors")
    
        // kubelet_docker_operations_errors_total
        for _, metric := range raw.FindByNames("kubelet_docker_operations_errors", "kubelet_docker_operations_errors_total") {
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 278..294
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 296..312
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 314..330

    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

        for _, metric := range raw.FindByName("kubelet_pleg_relist_interval_microseconds") {
            if math.IsNaN(metric.Value) {
                continue
            }
            quantile := metric.Labels.Get("quantile")
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 172..185

    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 177.

    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

        for _, metric := range raw.FindByName("kubelet_pleg_relist_latency_microseconds") {
            if math.IsNaN(metric.Value) {
                continue
            }
            quantile := metric.Labels.Get("quantile")
    src/go/collectors/go.d.plugin/modules/k8s_kubelet/collect.go on lines 158..171

    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 177.

    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