LibreNMS/Device/WirelessSensor.php
Method getTypes
has 87 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function getTypes($valid = false, $device_id = null)
{
// Add new types here translations/descriptions/units in lang/<lang>/wireless.php
// FIXME I'm really bad with icons, someone please help!
static $types = [
Method __construct
has 17 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
$type,
$device_id,
$oids,
$subtype,
$index,
Method channelToFrequency
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function channelToFrequency($channel): int
{
$channels = [
1 => 2412,
2 => 2417,
The method __construct has 17 parameters. Consider reducing the number of parameters to less than 10. Open
Open
public function __construct(
$type,
$device_id,
$oids,
$subtype,
- Exclude checks
The method getTypes has a boolean flag argument $valid, which is a certain sign of a Single Responsibility Principle violation. Open
Open
public static function getTypes($valid = false, $device_id = null)
- Read upRead up
- Exclude checks
BooleanArgumentFlag
Since: 1.4.0
A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.
Example
class Foo {
public function bar($flag = true) {
}
}
Source https://phpmd.org/rules/cleancode.html#booleanargumentflag
FIXME found Open
Open
// FIXME I'm really bad with icons, someone please help!
- Exclude checks
The property $translation_prefix is not named in camelCase. Open
Open
class WirelessSensor extends Sensor
{
protected static $name = 'Wireless Sensor';
protected static $table = 'wireless_sensors';
protected static $data_name = 'wireless-sensor';
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
Avoid variables with short names like $os. Configured minimum length is 3. Open
Open
public static function runDiscovery(OS $os)
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
The property $data_name is not named in camelCase. Open
Open
class WirelessSensor extends Sensor
{
protected static $name = 'Wireless Sensor';
protected static $table = 'wireless_sensors';
protected static $data_name = 'wireless-sensor';
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}
Source
The property $access_point_ip is not named in camelCase. Open
Open
class WirelessSensor extends Sensor
{
protected static $name = 'Wireless Sensor';
protected static $table = 'wireless_sensors';
protected static $data_name = 'wireless-sensor';
- Read upRead up
- Exclude checks
CamelCasePropertyName
Since: 0.2
It is considered best practice to use the camelCase notation to name attributes.
Example
class ClassName {
protected $property_name;
}