librenms/librenms

View on GitHub
LibreNMS/OS/Zyxelwlc.php

Summary

Maintainability
A
1 hr
Test Coverage

Method discoverWirelessApCount has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function discoverWirelessApCount()
    {
        $oid = '.1.3.6.1.4.1.890.1.15.3.3.1.1.0'; //  ZYXEL-ES-CAPWAP::capwapOnlineAP
        $number_ap = (int) snmp_get($this->getDeviceArray(), '.11.3.6.1.4.1.890.1.15.3.3.1.1.0', '-Ovq'); // ZYXEL-ES-CAPWAP::capwapOnlineAP

Severity: Minor
Found in LibreNMS/OS/Zyxelwlc.php - About 1 hr to fix

    Avoid using undefined variables such as '$sensors' which will lead to PHP notices.
    Open

            return $sensors;
    Severity: Minor
    Found in LibreNMS/OS/Zyxelwlc.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    Avoid using undefined variables such as '$sensors' which will lead to PHP notices.
    Open

            $sensors[] = new WirelessSensor(
    Severity: Minor
    Found in LibreNMS/OS/Zyxelwlc.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

    Source https://phpmd.org/rules/cleancode.html#undefinedvariable

    The method discoverWirelessApCount uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

            } else {
                $max_ap = 0;
            }
    Severity: Minor
    Found in LibreNMS/OS/Zyxelwlc.php by phpmd

    ElseExpression

    Since: 1.4.0

    An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

    Example

    class Foo
    {
        public function bar($flag)
        {
            if ($flag) {
                // one branch
            } else {
                // another branch
            }
        }
    }

    Source https://phpmd.org/rules/cleancode.html#elseexpression

    There are no issues that match your filters.

    Category
    Status