netdata/netdata

View on GitHub
src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go

Summary

Maintainability
F
4 days
Test Coverage

Method Windows.collectMSSQL has a Cognitive Complexity of 120 (exceeds 20 allowed). Consider refactoring.
Open

func (w *Windows) collectMSSQL(mx map[string]int64, pms prometheus.Series) {
    instances := make(map[string]bool)
    dbs := make(map[string]bool)
    px := "mssql_instance_"
    for _, pm := range pms.FindByName(metricMSSQLAccessMethodPageSplits) {
Severity: Minor
Found in src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go - About 2 days to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Method Windows.collectMSSQL has 207 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (w *Windows) collectMSSQL(mx map[string]int64, pms prometheus.Series) {
    instances := make(map[string]bool)
    dbs := make(map[string]bool)
    px := "mssql_instance_"
    for _, pm := range pms.FindByName(metricMSSQLAccessMethodPageSplits) {
Severity: Major
Found in src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go - About 7 hrs to fix

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

        for _, pm := range pms.FindByName(metricMSSQLDatabaseLogFlushed) {
            if name, db := pm.Labels.Get("mssql_instance"), pm.Labels.Get("database"); name != "" && db != "" {
                instances[name], dbs[name+":"+db] = true, true
                mx[px+db+"_instance_"+name+"_log_flushed_bytes"] = int64(pm.Value)
            }
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go and 6 other locations - About 55 mins to fix
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 182..187
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 188..193
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 194..199
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 206..211
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 212..217
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 218..223

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

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

        for _, pm := range pms.FindByName(metricMSSQLDatabaseDataFileSize) {
            if name, db := pm.Labels.Get("mssql_instance"), pm.Labels.Get("database"); name != "" && db != "" {
                instances[name], dbs[name+":"+db] = true, true
                mx[px+db+"_instance_"+name+"_data_files_size_bytes"] = int64(pm.Value)
            }
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go and 6 other locations - About 55 mins to fix
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 182..187
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 188..193
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 200..205
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 206..211
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 212..217
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 218..223

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

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

        for _, pm := range pms.FindByName(metricMSSQLDatabaseLogFlushes) {
            if name, db := pm.Labels.Get("mssql_instance"), pm.Labels.Get("database"); name != "" && db != "" {
                instances[name], dbs[name+":"+db] = true, true
                mx[px+db+"_instance_"+name+"_log_flushes"] = int64(pm.Value)
            }
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go and 6 other locations - About 55 mins to fix
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 182..187
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 188..193
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 194..199
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 200..205
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 212..217
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 218..223

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

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

        for _, pm := range pms.FindByName(metricMSSQLDatabaseTransactions) {
            if name, db := pm.Labels.Get("mssql_instance"), pm.Labels.Get("database"); name != "" && db != "" {
                instances[name], dbs[name+":"+db] = true, true
                mx[px+db+"_instance_"+name+"_transactions"] = int64(pm.Value)
            }
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go and 6 other locations - About 55 mins to fix
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 182..187
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 188..193
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 194..199
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 200..205
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 206..211
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 218..223

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

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

        for _, pm := range pms.FindByName(metricMSSQLDatabaseBackupRestoreOperations) {
            if name, db := pm.Labels.Get("mssql_instance"), pm.Labels.Get("database"); name != "" && db != "" {
                instances[name], dbs[name+":"+db] = true, true
                mx[px+db+"_instance_"+name+"_backup_restore_operations"] = int64(pm.Value)
            }
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go and 6 other locations - About 55 mins to fix
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 182..187
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 194..199
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 200..205
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 206..211
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 212..217
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 218..223

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

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

        for _, pm := range pms.FindByName(metricMSSQLDatabaseActiveTransactions) {
            if name, db := pm.Labels.Get("mssql_instance"), pm.Labels.Get("database"); name != "" && db != "" {
                instances[name], dbs[name+":"+db] = true, true
                mx[px+db+"_instance_"+name+"_active_transactions"] = int64(pm.Value)
            }
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go and 6 other locations - About 55 mins to fix
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 188..193
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 194..199
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 200..205
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 206..211
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 212..217
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 218..223

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

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

        for _, pm := range pms.FindByName(metricMSSQLDatabaseWriteTransactions) {
            if name, db := pm.Labels.Get("mssql_instance"), pm.Labels.Get("database"); name != "" && db != "" {
                instances[name], dbs[name+":"+db] = true, true
                mx[px+db+"_instance_"+name+"_write_transactions"] = int64(pm.Value)
            }
    Severity: Major
    Found in src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go and 6 other locations - About 55 mins to fix
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 182..187
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 188..193
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 194..199
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 200..205
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 206..211
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 212..217

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

    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 _, pm := range pms.FindByName(metricMSSQLDeadlocks) {
            if name := pm.Labels.Get("mssql_instance"); name != "" {
                instances[name] = true
                if res := pm.Labels.Get("resource"); res != "" {
                    mx[px+name+"_resource_"+res+"_locks_deadlocks"] = int64(pm.Value)
    Severity: Minor
    Found in src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go and 1 other location - About 45 mins to fix
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 101..108

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

    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 _, pm := range pms.FindByName(metricMSSQLLockWait) {
            if name := pm.Labels.Get("mssql_instance"); name != "" {
                instances[name] = true
                if res := pm.Labels.Get("resource"); res != "" {
                    mx[px+name+"_resource_"+res+"_locks_lock_wait_seconds"] = int64(pm.Value)
    Severity: Minor
    Found in src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go and 1 other location - About 45 mins to fix
    src/go/collectors/go.d.plugin/modules/windows/collect_mssql.go on lines 109..116

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

    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