librenms/librenms

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

Summary

Maintainability
F
1 wk
Test Coverage

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

<?php

use LibreNMS\Exceptions\JsonAppException;
use LibreNMS\Exceptions\JsonAppMissingKeysException;
use LibreNMS\RRD\RrdDefinition;
Severity: Minor
Found in includes/polling/applications/zfs.inc.php - About 2 hrs to fix

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

    $rrd_def = RrdDefinition::make()
        ->addDataset('deleted', 'DERIVE', 0)
        ->addDataset('evict_skip', 'DERIVE', 0)
        ->addDataset('mutex_skip', 'DERIVE', 0)
        ->addDataset('recycle_miss', 'DERIVE', 0)
    Severity: Major
    Found in includes/polling/applications/zfs.inc.php and 1 other location - About 3 days to fix
    includes/polling/applications/nfs-v3-stats.inc.php on lines 10..63

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

    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

    $rrd_def = RrdDefinition::make()
        ->addDataset('l2_abort_lowmem', 'DERIVE', 0)
        ->addDataset('l2_access_total', 'DERIVE', 0)
        ->addDataset('l2_asize', 'GAUGE', 0)
        ->addDataset('l2_bufc_d_asize', 'GAUGE', 0)
    Severity: Major
    Found in includes/polling/applications/zfs.inc.php and 1 other location - About 2 days to fix
    includes/polling/applications/bind.inc.php on lines 534..577

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

    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

    if (count($added_pools) > 0 || count($removed_pools) > 0) {
        $log_message = 'ZFS Pool Change:';
        $log_message .= count($added_pools) > 0 ? ' Added ' . implode(',', $added_pools) : '';
        $log_message .= count($removed_pools) > 0 ? ' Removed ' . implode(',', $added_pools) : '';
        log_event($log_message, $device, 'application');
    Severity: Major
    Found in includes/polling/applications/zfs.inc.php and 2 other locations - About 2 hrs to fix
    includes/polling/applications/ss.inc.php on lines 191..196
    includes/polling/applications/ss.inc.php on lines 201..206

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

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

    try {
        $zfs = json_app_get($device, $name, 1)['data'];
    } catch (JsonAppMissingKeysException $e) {
        //old version with out the data key
        $zfs = $e->getParsedJson();
    Severity: Major
    Found in includes/polling/applications/zfs.inc.php and 11 other locations - About 2 hrs to fix
    includes/polling/applications/backupninja.inc.php on lines 11..20
    includes/polling/applications/certificate.inc.php on lines 10..19
    includes/polling/applications/linux_config_files.inc.php on lines 11..20
    includes/polling/applications/mdadm.inc.php on lines 10..19
    includes/polling/applications/puppet-agent.inc.php on lines 10..19
    includes/polling/applications/pureftpd.inc.php on lines 10..19
    includes/polling/applications/pwrstatd.inc.php on lines 10..19
    includes/polling/applications/redis.inc.php on lines 18..27
    includes/polling/applications/seafile.inc.php on lines 10..19
    includes/polling/applications/ss.inc.php on lines 47..56
    includes/polling/applications/wireguard.inc.php on lines 11..26

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

    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

    $pool_rrd_def = RrdDefinition::make()
        ->addDataset('size', 'GAUGE', 0)
        ->addDataset('alloc', 'GAUGE', 0)
        ->addDataset('free', 'GAUGE', 0)
        ->addDataset('expandsz', 'GAUGE', 0)
    Severity: Major
    Found in includes/polling/applications/zfs.inc.php and 3 other locations - About 45 mins to fix
    includes/polling/applications/mdadm.inc.php on lines 22..29
    includes/polling/applications/opensearch.inc.php on lines 144..151
    includes/polling/applications/sneck.inc.php on lines 41..48

    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