librenms/librenms

View on GitHub
LibreNMS/OS/Gaia.php

Summary

Maintainability
B
6 hrs
Test Coverage

Method pollOS has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function pollOS(DataStorageInterface $datastore): void
    {
        $oids = ['fwLoggingHandlingRate.0', 'mgLSLogReceiveRate.0', 'fwNumConn.0', 'fwAccepted.0', 'fwRejected.0', 'fwDropped.0', 'fwLogged.0'];

        $data = snmp_get_multi($this->getDeviceArray(), $oids, '-OQUs', 'CHECKPOINT-MIB');
Severity: Minor
Found in LibreNMS/OS/Gaia.php - About 1 hr to fix

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

            if (is_numeric($data[0]['fwNumConn'] ?? null)) {
                $rrd_def = RrdDefinition::make()->addDataset('NumConn', 'GAUGE', 0);
    
                $fields = [
                    'NumConn' => $data[0]['fwNumConn'],
    Severity: Major
    Found in LibreNMS/OS/Gaia.php and 12 other locations - About 1 hr to fix
    LibreNMS/OS/Gaia.php on lines 20..30
    LibreNMS/OS/Gaia.php on lines 35..45
    LibreNMS/OS/Pfsense.php on lines 50..61
    LibreNMS/OS/Pfsense.php on lines 63..74
    LibreNMS/OS/Pfsense.php on lines 76..87
    LibreNMS/OS/Pfsense.php on lines 89..100
    LibreNMS/OS/Pfsense.php on lines 102..113
    LibreNMS/OS/Pfsense.php on lines 115..126
    LibreNMS/OS/Pfsense.php on lines 128..139
    LibreNMS/OS/Pfsense.php on lines 141..152
    LibreNMS/OS/Pfsense.php on lines 154..165
    LibreNMS/OS/Pfsense.php on lines 167..178

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

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

            if (is_numeric($data[0]['mgLSLogReceiveRate'] ?? null)) {
                $rrd_def = RrdDefinition::make()->addDataset('LogReceiveRate', 'GAUGE', 0);
    
                $fields = [
                    'LogReceiveRate' => $data[0]['mgLSLogReceiveRate'],
    Severity: Major
    Found in LibreNMS/OS/Gaia.php and 12 other locations - About 1 hr to fix
    LibreNMS/OS/Gaia.php on lines 20..30
    LibreNMS/OS/Gaia.php on lines 50..60
    LibreNMS/OS/Pfsense.php on lines 50..61
    LibreNMS/OS/Pfsense.php on lines 63..74
    LibreNMS/OS/Pfsense.php on lines 76..87
    LibreNMS/OS/Pfsense.php on lines 89..100
    LibreNMS/OS/Pfsense.php on lines 102..113
    LibreNMS/OS/Pfsense.php on lines 115..126
    LibreNMS/OS/Pfsense.php on lines 128..139
    LibreNMS/OS/Pfsense.php on lines 141..152
    LibreNMS/OS/Pfsense.php on lines 154..165
    LibreNMS/OS/Pfsense.php on lines 167..178

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

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

            if (is_numeric($data[0]['fwLoggingHandlingRate'] ?? null)) {
                $rrd_def = RrdDefinition::make()->addDataset('fwlograte', 'GAUGE', 0);
    
                $fields = [
                    'fwlograte' => $data[0]['fwLoggingHandlingRate'],
    Severity: Major
    Found in LibreNMS/OS/Gaia.php and 12 other locations - About 1 hr to fix
    LibreNMS/OS/Gaia.php on lines 35..45
    LibreNMS/OS/Gaia.php on lines 50..60
    LibreNMS/OS/Pfsense.php on lines 50..61
    LibreNMS/OS/Pfsense.php on lines 63..74
    LibreNMS/OS/Pfsense.php on lines 76..87
    LibreNMS/OS/Pfsense.php on lines 89..100
    LibreNMS/OS/Pfsense.php on lines 102..113
    LibreNMS/OS/Pfsense.php on lines 115..126
    LibreNMS/OS/Pfsense.php on lines 128..139
    LibreNMS/OS/Pfsense.php on lines 141..152
    LibreNMS/OS/Pfsense.php on lines 154..165
    LibreNMS/OS/Pfsense.php on lines 167..178

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

    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