LibreNMS/OS/Zyxelwlc.php
Method discoverWirelessApCount
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Avoid using undefined variables such as '$sensors' which will lead to PHP notices. Open
Open
return $sensors;
- Read upRead up
- Exclude checks
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
Open
$sensors[] = new WirelessSensor(
- Read upRead up
- Exclude checks
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
Open
} else {
$max_ap = 0;
}
- Read upRead up
- Exclude checks
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
}
}
}