netdata/netdata

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

Summary

Maintainability
A
3 hrs
Test Coverage

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

func (f *Fail2Ban) addJailCharts(jail string) {
    charts := jailChartsTmpl.Copy()

    for _, chart := range *charts {
        chart.ID = fmt.Sprintf(chart.ID, jail)
Severity: Major
Found in src/go/collectors/go.d.plugin/modules/fail2ban/charts.go and 22 other locations - About 1 hr to fix
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/mongodb/collect_sharding.go on lines 66..83
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

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

var (
    jailCurrentBannedIPs = module.Chart{
        ID:       "jail_%s_banned_ips",
        Title:    "Fail2Ban Jail banned IPs",
        Units:    "addresses",
Severity: Major
Found in src/go/collectors/go.d.plugin/modules/fail2ban/charts.go and 1 other location - About 1 hr to fix
src/go/collectors/go.d.plugin/modules/megacli/charts.go on lines 49..74

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

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