librenms/librenms

View on GitHub
LibreNMS/Device/WirelessSensor.php

Summary

Maintainability
C
7 hrs
Test Coverage

Method getTypes has 87 lines of code (exceeds 25 allowed). Consider refactoring.
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 = [
Severity: Major
Found in LibreNMS/Device/WirelessSensor.php - About 3 hrs to fix

    Method __construct has 17 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            $type,
            $device_id,
            $oids,
            $subtype,
            $index,
    Severity: Major
    Found in LibreNMS/Device/WirelessSensor.php - About 2 hrs to fix

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

          public static function channelToFrequency($channel): int
          {
              $channels = [
                  1 => 2412,
                  2 => 2417,
      Severity: Minor
      Found in LibreNMS/Device/WirelessSensor.php - About 1 hr to fix

        The method __construct has 17 parameters. Consider reducing the number of parameters to less than 10.
        Open

            public function __construct(
                $type,
                $device_id,
                $oids,
                $subtype,
        Severity: Minor
        Found in LibreNMS/Device/WirelessSensor.php by phpmd

        The method getTypes has a boolean flag argument $valid, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public static function getTypes($valid = false, $device_id = null)
        Severity: Minor
        Found in LibreNMS/Device/WirelessSensor.php by phpmd

        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

                // FIXME I'm really bad with icons, someone please help!
        Severity: Minor
        Found in LibreNMS/Device/WirelessSensor.php by fixme

        The property $translation_prefix is not named in camelCase.
        Open

        class WirelessSensor extends Sensor
        {
            protected static $name = 'Wireless Sensor';
            protected static $table = 'wireless_sensors';
            protected static $data_name = 'wireless-sensor';
        Severity: Minor
        Found in LibreNMS/Device/WirelessSensor.php by phpmd

        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

            public static function runDiscovery(OS $os)
        Severity: Minor
        Found in LibreNMS/Device/WirelessSensor.php by phpmd

        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

        class WirelessSensor extends Sensor
        {
            protected static $name = 'Wireless Sensor';
            protected static $table = 'wireless_sensors';
            protected static $data_name = 'wireless-sensor';
        Severity: Minor
        Found in LibreNMS/Device/WirelessSensor.php by phpmd

        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

        class WirelessSensor extends Sensor
        {
            protected static $name = 'Wireless Sensor';
            protected static $table = 'wireless_sensors';
            protected static $data_name = 'wireless-sensor';
        Severity: Minor
        Found in LibreNMS/Device/WirelessSensor.php by phpmd

        CamelCasePropertyName

        Since: 0.2

        It is considered best practice to use the camelCase notation to name attributes.

        Example

        class ClassName {
            protected $property_name;
        }

        Source

        There are no issues that match your filters.

        Category
        Status