netdata/netdata

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

Summary

Maintainability
D
2 days
Test Coverage

Method Envoy.collectClusterUpstreamStats has 75 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (e *Envoy) collectClusterUpstreamStats(mx map[string]int64, mfs prometheus.MetricFamilies) {
    seen := make(map[string]bool)
    for _, n := range []string{
        "envoy_cluster_upstream_cx_total",
        "envoy_cluster_upstream_cx_http1_total",
Severity: Minor
Found in src/go/collectors/go.d.plugin/modules/envoy/collect.go - About 2 hrs to fix

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

    func (e *Envoy) collectListenerDownstreamStats(mx map[string]int64, mfs prometheus.MetricFamilies) {
        seen := make(map[string]bool)
        for _, n := range []string{
            "envoy_listener_downstream_cx_total",
            "envoy_listener_downstream_cx_destroy",
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/envoy/collect.go and 1 other location - About 6 hrs to fix
    src/go/collectors/go.d.plugin/modules/envoy/collect.go on lines 127..175

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

    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 (e *Envoy) collectListenerAdminDownstreamStats(mx map[string]int64, mfs prometheus.MetricFamilies) {
        seen := make(map[string]bool)
        for _, n := range []string{
            "envoy_listener_admin_downstream_cx_total",
            "envoy_listener_admin_downstream_cx_destroy",
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/envoy/collect.go and 1 other location - About 6 hrs to fix
    src/go/collectors/go.d.plugin/modules/envoy/collect.go on lines 177..225

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

    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 _, n := range []string{
            "envoy_cluster_manager_cluster_added",
            "envoy_cluster_manager_cluster_modified",
            "envoy_cluster_manager_cluster_removed",
            "envoy_cluster_manager_cluster_updated",
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/envoy/collect.go and 1 other location - About 1 hr to fix
    src/go/collectors/go.d.plugin/modules/envoy/collect.go on lines 313..333

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

    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 _, n := range []string{
            "envoy_listener_manager_listener_added",
            "envoy_listener_manager_listener_modified",
            "envoy_listener_manager_listener_removed",
            "envoy_listener_manager_listener_stopped",
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/envoy/collect.go and 1 other location - About 1 hr to fix
    src/go/collectors/go.d.plugin/modules/envoy/collect.go on lines 87..107

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

    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 (e *Envoy) collectGauge(mfs prometheus.MetricFamilies, metric string, process func(name string, m prometheus.Metric)) {
        if mf := mfs.GetGauge(metric); mf != nil {
            for _, m := range mf.Metrics() {
                process(mf.Name(), m)
            }
    Severity: Minor
    Found in src/go/collectors/go.d.plugin/modules/envoy/collect.go and 1 other location - About 40 mins to fix
    src/go/collectors/go.d.plugin/modules/envoy/collect.go on lines 369..375

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

    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 (e *Envoy) collectCounter(mfs prometheus.MetricFamilies, metric string, process func(name string, m prometheus.Metric)) {
        if mf := mfs.GetCounter(metric); mf != nil {
            for _, m := range mf.Metrics() {
                process(mf.Name(), m)
            }
    Severity: Minor
    Found in src/go/collectors/go.d.plugin/modules/envoy/collect.go and 1 other location - About 40 mins to fix
    src/go/collectors/go.d.plugin/modules/envoy/collect.go on lines 361..367

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

    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