librenms/librenms

View on GitHub
includes/polling/applications/opensearch.inc.php

Summary

Maintainability
D
1 day
Test Coverage

File opensearch.inc.php has 268 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

use LibreNMS\Exceptions\JsonAppException;
use LibreNMS\RRD\RrdDefinition;

Severity: Minor
Found in includes/polling/applications/opensearch.inc.php - About 2 hrs to fix

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

    $rrd_def = RrdDefinition::make()
        ->addDataset('tseg_count', 'GAUGE', 0)
        ->addDataset('tseg_size', 'GAUGE', 0)
        ->addDataset('tseg_terms_size', 'GAUGE', 0)
        ->addDataset('tseg_fields_size', 'GAUGE', 0)
    Severity: Major
    Found in includes/polling/applications/opensearch.inc.php and 18 other locations - About 3 hrs to fix
    LibreNMS/OS/Shared/Cisco.php on lines 463..474
    includes/polling/applications/cape.inc.php on lines 65..76
    includes/polling/applications/cape.inc.php on lines 96..107
    includes/polling/applications/cape.inc.php on lines 127..138
    includes/polling/applications/cape.inc.php on lines 158..169
    includes/polling/applications/cape.inc.php on lines 189..200
    includes/polling/applications/cape.inc.php on lines 220..231
    includes/polling/applications/cape.inc.php on lines 251..262
    includes/polling/applications/cape.inc.php on lines 282..293
    includes/polling/applications/cape.inc.php on lines 313..324
    includes/polling/applications/cape.inc.php on lines 344..355
    includes/polling/applications/cape.inc.php on lines 375..386
    includes/polling/applications/cape.inc.php on lines 406..417
    includes/polling/applications/cape.inc.php on lines 437..448
    includes/polling/applications/cape.inc.php on lines 468..479
    includes/polling/applications/hv-monitor.inc.php on lines 246..257
    includes/polling/applications/pi-hole.inc.php on lines 28..39
    includes/polling/applications/sdfsinfo.inc.php on lines 33..44

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

    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

    $metrics = [
        'c_nodes' => $data['c_nodes'],
        'c_data_nodes' => $data['c_data_nodes'],
        'c_act_pri_shards' => $data['c_act_pri_shards'],
        'c_act_shards' => $data['c_act_shards'],
    Severity: Major
    Found in includes/polling/applications/opensearch.inc.php and 1 other location - About 2 hrs to fix
    includes/polling/applications/chronyd.inc.php on lines 71..85

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

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

    $metrics = [
        'tseg_count' => $data['tseg_count'],
        'tseg_size' => $data['tseg_size'],
        'tseg_terms_size' => $data['tseg_terms_size'],
        'tseg_fields_size' => $data['tseg_fields_size'],
    Severity: Major
    Found in includes/polling/applications/opensearch.inc.php and 16 other locations - About 1 hr to fix
    includes/polling/applications/cape.inc.php on lines 77..89
    includes/polling/applications/cape.inc.php on lines 108..120
    includes/polling/applications/cape.inc.php on lines 139..151
    includes/polling/applications/cape.inc.php on lines 170..182
    includes/polling/applications/cape.inc.php on lines 201..213
    includes/polling/applications/cape.inc.php on lines 232..244
    includes/polling/applications/cape.inc.php on lines 263..275
    includes/polling/applications/cape.inc.php on lines 294..306
    includes/polling/applications/cape.inc.php on lines 325..337
    includes/polling/applications/cape.inc.php on lines 356..368
    includes/polling/applications/cape.inc.php on lines 387..399
    includes/polling/applications/cape.inc.php on lines 418..430
    includes/polling/applications/cape.inc.php on lines 449..461
    includes/polling/applications/cape.inc.php on lines 480..492
    includes/polling/applications/drbd.inc.php on lines 28..40
    includes/polling/applications/hv-monitor.inc.php on lines 265..277

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

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

    $rrd_def = RrdDefinition::make()
        ->addDataset('ti_total', 'DERIVE', 0)
        ->addDataset('ti_time', 'DERIVE', 0)
        ->addDataset('ti_failed', 'DERIVE', 0)
        ->addDataset('ti_del_total', 'DERIVE', 0)
    Severity: Major
    Found in includes/polling/applications/opensearch.inc.php and 4 other locations - About 1 hr to fix
    includes/polling/applications/opensearch.inc.php on lines 93..101
    includes/polling/applications/php-fpm.inc.php on lines 19..27
    includes/polling/applications/redis.inc.php on lines 105..113
    includes/polling/ports/cisco-if-extension.inc.php on lines 27..35

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

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

    $rrd_def = RrdDefinition::make()
        ->addDataset('ts_q_total', 'DERIVE', 0)
        ->addDataset('ts_q_time', 'DERIVE', 0)
        ->addDataset('ts_f_total', 'DERIVE', 0)
        ->addDataset('ts_f_time', 'DERIVE', 0)
    Severity: Major
    Found in includes/polling/applications/opensearch.inc.php and 4 other locations - About 1 hr to fix
    includes/polling/applications/opensearch.inc.php on lines 70..78
    includes/polling/applications/php-fpm.inc.php on lines 19..27
    includes/polling/applications/redis.inc.php on lines 105..113
    includes/polling/ports/cisco-if-extension.inc.php on lines 27..35

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

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

    try {
        $returned = json_app_get($device, 'opensearch');
    } catch (JsonAppException $e) {
        echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL;
        update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message
    Severity: Major
    Found in includes/polling/applications/opensearch.inc.php and 2 other locations - About 55 mins to fix
    includes/polling/applications/sagan.inc.php on lines 12..19
    includes/polling/applications/suricata.inc.php on lines 7..14

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

    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

    $rrd_def = RrdDefinition::make()
        ->addDataset('tqc_size', 'GAUGE', 0)
        ->addDataset('tqc_total', 'GAUGE', 0)
        ->addDataset('tqc_hit', 'DERIVE', 0)
        ->addDataset('tqc_miss', 'DERIVE', 0)
    Severity: Major
    Found in includes/polling/applications/opensearch.inc.php and 3 other locations - About 45 mins to fix
    includes/polling/applications/mdadm.inc.php on lines 22..29
    includes/polling/applications/sneck.inc.php on lines 41..48
    includes/polling/applications/zfs.inc.php on lines 239..246

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

    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