netdata/netdata

View on GitHub
src/go/collectors/go.d.plugin/modules/mongodb/collect_sharding.go

Summary

Maintainability
A
2 hrs
Test Coverage

Method Mongo.collectSharding has 5 return statements (exceeds 4 allowed).
Open

func (m *Mongo) collectSharding(mx map[string]int64) error {
    nodes, err := m.conn.shardNodes()
    if err != nil {
        return err
    }
Severity: Major
Found in src/go/collectors/go.d.plugin/modules/mongodb/collect_sharding.go - About 35 mins to fix

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

    func (m *Mongo) addShardCharts(id string) {
        charts := chartsTmplShardingShard.Copy()
    
        for _, chart := range *charts {
            chart.ID = fmt.Sprintf(chart.ID, id)
    src/go/collectors/go.d.plugin/modules/fail2ban/charts.go on lines 49..65
    src/go/collectors/go.d.plugin/modules/logstash/charts.go on lines 211..227
    src/go/collectors/go.d.plugin/modules/mongodb/collect_dbstats.go on lines 73..89
    src/go/collectors/go.d.plugin/modules/nginxplus/charts.go on lines 759..775
    src/go/collectors/go.d.plugin/modules/nginxplus/charts.go on lines 782..798
    src/go/collectors/go.d.plugin/modules/nginxplus/charts.go on lines 805..821
    src/go/collectors/go.d.plugin/modules/nginxplus/charts.go on lines 878..894
    src/go/collectors/go.d.plugin/modules/nginxplus/charts.go on lines 951..967
    src/go/collectors/go.d.plugin/modules/nvme/charts.go on lines 240..256
    src/go/collectors/go.d.plugin/modules/windows/charts.go on lines 4191..4207
    src/go/collectors/go.d.plugin/modules/windows/charts.go on lines 4222..4238
    src/go/collectors/go.d.plugin/modules/windows/charts.go on lines 4245..4261
    src/go/collectors/go.d.plugin/modules/windows/charts.go on lines 4316..4332
    src/go/collectors/go.d.plugin/modules/windows/charts.go on lines 4339..4355
    src/go/collectors/go.d.plugin/modules/windows/charts.go on lines 4362..4378
    src/go/collectors/go.d.plugin/modules/windows/charts.go on lines 4385..4401
    src/go/collectors/go.d.plugin/modules/windows/charts.go on lines 4408..4424
    src/go/collectors/go.d.plugin/modules/windows/charts.go on lines 4455..4471
    src/go/collectors/go.d.plugin/modules/windows/charts.go on lines 4494..4510
    src/go/collectors/go.d.plugin/modules/windows/charts.go on lines 4776..4792
    src/go/collectors/go.d.plugin/modules/windows/charts.go on lines 4799..4815
    src/go/collectors/go.d.plugin/modules/zfspool/charts.go on lines 88..104

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

    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