Apply fixes from StyleCI (#15101)

Co-authored-by: StyleCI Bot <bot@styleci.io>
This commit is contained in:
Jellyfrog
2023-06-13 13:35:00 +02:00
committed by GitHub
parent e547945985
commit b14e2d4609
28 changed files with 38 additions and 51 deletions

View File

@@ -3,7 +3,6 @@
namespace LibreNMS\Authentication; namespace LibreNMS\Authentication;
use ErrorException; use ErrorException;
use LDAP\Connection;
use LibreNMS\Config; use LibreNMS\Config;
use LibreNMS\Exceptions\AuthenticationException; use LibreNMS\Exceptions\AuthenticationException;
use LibreNMS\Exceptions\LdapMissingException; use LibreNMS\Exceptions\LdapMissingException;

View File

@@ -2,7 +2,6 @@
namespace LibreNMS\Authentication; namespace LibreNMS\Authentication;
use Illuminate\Support\Facades\Auth;
use LibreNMS\Config; use LibreNMS\Config;
use LibreNMS\Interfaces\Authentication\Authorizer; use LibreNMS\Interfaces\Authentication\Authorizer;

View File

@@ -26,7 +26,6 @@
namespace LibreNMS\Exceptions; namespace LibreNMS\Exceptions;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Http\Response;
use LibreNMS\Interfaces\Exceptions\UpgradeableException; use LibreNMS\Interfaces\Exceptions\UpgradeableException;
class DatabaseConnectException extends \Exception implements UpgradeableException class DatabaseConnectException extends \Exception implements UpgradeableException

View File

@@ -81,15 +81,15 @@ class Allied extends OS implements OSDiscovery
$hardware = $c; $hardware = $c;
$serial = snmp_get($this->getDeviceArray(), 'arBoardSerialNumber.1', '-OsvQU', 'AT-INTERFACES-MIB'); $serial = snmp_get($this->getDeviceArray(), 'arBoardSerialNumber.1', '-OsvQU', 'AT-INTERFACES-MIB');
// sysDescr.0 = STRING: "CentreCOM 9924Ts, version 3.2.1-04, built 08-Sep-2009" // sysDescr.0 = STRING: "CentreCOM 9924Ts, version 3.2.1-04, built 08-Sep-2009"
} elseif ($a == 'CentreCOM' && $c == 'version') { } elseif ($a == 'CentreCOM' && $c == 'version') {
$version = $d; $version = $d;
$features = $f; $features = $f;
$hardware = snmp_get($this->getDeviceArray(), 'arBoardName.1', '-OsvQU', 'AT-INTERFACES-MIB'); $hardware = snmp_get($this->getDeviceArray(), 'arBoardName.1', '-OsvQU', 'AT-INTERFACES-MIB');
$serial = snmp_get($this->getDeviceArray(), 'arBoardSerialNumber.1', '-OsvQU', 'AT-INTERFACES-MIB'); $serial = snmp_get($this->getDeviceArray(), 'arBoardSerialNumber.1', '-OsvQU', 'AT-INTERFACES-MIB');
//AT-GS950/24 Gigabit Ethernet WebSmart Switch //AT-GS950/24 Gigabit Ethernet WebSmart Switch
//Also requires system description as no OIDs provide $hardware //Also requires system description as no OIDs provide $hardware
} elseif ($d == 'WebSmart' && $e == 'Switch') { } elseif ($d == 'WebSmart' && $e == 'Switch') {
$version = snmp_get($this->getDeviceArray(), 'swhub.167.81.1.3.0', '-OsvQU', 'AtiL2-MIB'); $version = snmp_get($this->getDeviceArray(), 'swhub.167.81.1.3.0', '-OsvQU', 'AtiL2-MIB');
$version = $d . ' ' . $version; $version = $d . ' ' . $version;

View File

@@ -27,7 +27,6 @@ namespace LibreNMS\Util;
use App\Models\Device; use App\Models\Device;
use App\Models\Port; use App\Models\Port;
use App\Models\Sensor;
use Carbon\Carbon; use Carbon\Carbon;
use Carbon\CarbonImmutable; use Carbon\CarbonImmutable;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;

View File

@@ -45,7 +45,7 @@ class PortFieldController extends SelectController
/** /**
* Defines fields that can be used as filters * Defines fields that can be used as filters
* *
* @param $request * @param $request
* @return string[] * @return string[]
*/ */
protected function filterFields($request) protected function filterFields($request)

View File

@@ -27,7 +27,6 @@ namespace App\Http\Controllers\Widgets;
use App\Models\Device; use App\Models\Device;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use LibreNMS\Config;
use LibreNMS\DB\Eloquent; use LibreNMS\DB\Eloquent;
class DeviceTypeController extends WidgetController class DeviceTypeController extends WidgetController

View File

@@ -2,7 +2,6 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use App\Models\User;
use Closure; use Closure;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;

View File

@@ -4,7 +4,6 @@ namespace App\Http\Requests;
use Hash; use Hash;
use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Validator;
use LibreNMS\Config; use LibreNMS\Config;
class UpdateUserRequest extends FormRequest class UpdateUserRequest extends FormRequest

View File

@@ -2,7 +2,6 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use LibreNMS\Interfaces\Models\Keyable; use LibreNMS\Interfaces\Models\Keyable;

View File

@@ -2,7 +2,6 @@
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use LibreNMS\Interfaces\Models\Keyable; use LibreNMS\Interfaces\Models\Keyable;

View File

@@ -833,7 +833,7 @@ function mw_to_dbm($value)
} }
/** /**
* @param $value * @param $value
* @param null $default * @param null $default
* @param int $min * @param int $min
* @return null * @return null

View File

@@ -503,7 +503,7 @@ function dbRollbackTransaction()
* Generate a string of placeholders to pass to fill in a list * Generate a string of placeholders to pass to fill in a list
* result will look like this: (?, ?, ?, ?) * result will look like this: (?, ?, ?, ?)
* *
* @param $count * @param $count
* @return string placholder list * @return string placholder list
* *
* @deprecated Please use Eloquent instead; https://laravel.com/docs/eloquent * @deprecated Please use Eloquent instead; https://laravel.com/docs/eloquent

View File

@@ -23,7 +23,6 @@
* @author Chris Malton (@cjsoftuk) * @author Chris Malton (@cjsoftuk)
*/ */
use App\Models\Vrf;
use LibreNMS\Config; use LibreNMS\Config;
use LibreNMS\Util\IP; use LibreNMS\Util\IP;

View File

@@ -847,10 +847,10 @@ function ignore_storage($os, $descr)
} }
/** /**
* @param $valid * @param $valid
* @param OS $os * @param OS $os
* @param $sensor_type * @param $sensor_type
* @param $pre_cache * @param $pre_cache
*/ */
function discovery_process(&$valid, $os, $sensor_class, $pre_cache) function discovery_process(&$valid, $os, $sensor_class, $pre_cache)
{ {
@@ -1003,7 +1003,7 @@ function discovery_process(&$valid, $os, $sensor_class, $pre_cache)
} }
/** /**
* @param $types * @param $types
* @param OS $os * @param OS $os
* @param array $pre_cache * @param array $pre_cache
*/ */
@@ -1200,7 +1200,7 @@ function add_cbgp_peer($device, $peer, $afi, $safi)
/** /**
* check if we should skip this sensor from discovery * check if we should skip this sensor from discovery
* *
* @param $device * @param $device
* @param string $sensor_class * @param string $sensor_class
* @param string $sensor_descr * @param string $sensor_descr
* @return bool * @return bool

View File

@@ -132,7 +132,7 @@ if (Config::get('enable_libvirt') && $device['os'] == 'linux') {
) { ) {
dbUpdate(['vmwVmState' => $vmwVmState, 'vmwVmGuestOS' => $vmwVmGuestOS, 'vmwVmDisplayName' => $vmwVmDisplayName, 'vmwVmMemSize' => $vmwVmMemSize, 'vmwVmCpus' => $vmwVmCpus], 'vminfo', "device_id=? AND vm_type='libvirt' AND vmwVmVMID=?", [$device['device_id'], $dom_id]); dbUpdate(['vmwVmState' => $vmwVmState, 'vmwVmGuestOS' => $vmwVmGuestOS, 'vmwVmDisplayName' => $vmwVmDisplayName, 'vmwVmMemSize' => $vmwVmMemSize, 'vmwVmCpus' => $vmwVmCpus], 'vminfo', "device_id=? AND vm_type='libvirt' AND vmwVmVMID=?", [$device['device_id'], $dom_id]);
echo 'U'; echo 'U';
// FIXME eventlog // FIXME eventlog
} else { } else {
echo '.'; echo '.';
} }

View File

@@ -206,7 +206,7 @@ if ($device['os_group'] == 'cisco') {
[, $tmp_ifindex] = explode('.', $entAliasMappingIdentifier); [, $tmp_ifindex] = explode('.', $entAliasMappingIdentifier);
} }
break; break;
//or sensor entity has a parent entity with module class and entPhysicalName set to an existing ifName. //or sensor entity has a parent entity with module class and entPhysicalName set to an existing ifName.
} elseif ($entPhysicalClass === 'module' && array_key_exists($entPhysicalName, $port_reverse_array)) { } elseif ($entPhysicalClass === 'module' && array_key_exists($entPhysicalName, $port_reverse_array)) {
$tmp_ifindex = $port_reverse_array[$entPhysicalName]['ifIndex']; $tmp_ifindex = $port_reverse_array[$entPhysicalName]['ifIndex'];
break; break;

View File

@@ -46,7 +46,7 @@ if (($device['os'] == 'vmware-esxi') || ($device['os'] == 'linux')) {
$vmid = dbInsert(['device_id' => $device['device_id'], 'vm_type' => 'vmware', 'vmwVmVMID' => $index, 'vmwVmDisplayName' => $vmwVmDisplayName, 'vmwVmGuestOS' => $vmwVmGuestOS, 'vmwVmMemSize' => $vmwVmMemSize, 'vmwVmCpus' => $vmwVmCpus, 'vmwVmState' => $vmwVmState], 'vminfo'); $vmid = dbInsert(['device_id' => $device['device_id'], 'vm_type' => 'vmware', 'vmwVmVMID' => $index, 'vmwVmDisplayName' => $vmwVmDisplayName, 'vmwVmGuestOS' => $vmwVmGuestOS, 'vmwVmMemSize' => $vmwVmMemSize, 'vmwVmCpus' => $vmwVmCpus, 'vmwVmState' => $vmwVmState], 'vminfo');
log_event($vmwVmDisplayName . " ($vmwVmMemSize GB / $vmwVmCpus vCPU) Discovered", $device, 'system', 3, $vmid); log_event($vmwVmDisplayName . " ($vmwVmMemSize GB / $vmwVmCpus vCPU) Discovered", $device, 'system', 3, $vmid);
echo '+'; echo '+';
// FIXME eventlog // FIXME eventlog
} else { } else {
echo '.'; echo '.';
} }

View File

@@ -121,7 +121,7 @@ function percent_colour($perc)
} }
/** /**
* @param $device * @param $device
* @return string the path to the icon image for this device. Close to square. * @return string the path to the icon image for this device. Close to square.
*/ */
function getIcon($device) function getIcon($device)
@@ -130,7 +130,7 @@ function getIcon($device)
} }
/** /**
* @param $device * @param $device
* @return string an image tag with the icon for this device. Close to square. * @return string an image tag with the icon for this device. Close to square.
*/ */
function getIconTag($device) function getIconTag($device)
@@ -1341,7 +1341,7 @@ function get_schema_list()
} }
/** /**
* @param $device * @param $device
* @return int|null * @return int|null
*/ */
function get_device_oid_limit($device) function get_device_oid_limit($device)

View File

@@ -445,9 +445,9 @@ function rrd_get_color($code, $line = true)
/** /**
* Draw RRD file based on it's structure * Draw RRD file based on it's structure
* *
* @param $host * @param $host
* @param $plugin * @param $plugin
* @param $type * @param $type
* @param null $pinst * @param null $pinst
* @param null $tinst * @param null $tinst
* @param array $opts * @param array $opts
@@ -618,10 +618,10 @@ function collectd_draw_rrd($host, $plugin, $type, $pinst = null, $tinst = null,
/** /**
* Draw RRD file based on it's structure * Draw RRD file based on it's structure
* *
* @param $timespan * @param $timespan
* @param $host * @param $host
* @param $plugin * @param $plugin
* @param $type * @param $type
* @param null $pinst * @param null $pinst
* @param null $tinst * @param null $tinst
* @return false|string Commandline to call RRDGraph in order to generate the final graph* @internal param $ * @return false|string Commandline to call RRDGraph in order to generate the final graph* @internal param $

View File

@@ -825,7 +825,7 @@ function dynamic_override_config($type, $name, $device)
* One or an array of strings can be provided as an argument; if an array is passed, all ports matching * One or an array of strings can be provided as an argument; if an array is passed, all ports matching
* any of the types in the array are returned. * any of the types in the array are returned.
* *
* @param $types mixed String or strings matching 'port_descr_type's. * @param $types mixed String or strings matching 'port_descr_type's.
* @return array Rows from the ports table for matching ports. * @return array Rows from the ports table for matching ports.
*/ */
function get_ports_from_type($given_types) function get_ports_from_type($given_types)
@@ -877,8 +877,8 @@ function get_ports_from_type($given_types)
} }
/** /**
* @param $filename * @param $filename
* @param $content * @param $content
*/ */
function file_download($filename, $content) function file_download($filename, $content)
{ {
@@ -938,7 +938,7 @@ function search_oxidized_config($search_in_conf_textbox)
} }
/** /**
* @param $data * @param $data
* @return bool|mixed * @return bool|mixed
*/ */
function array_to_htmljson($data) function array_to_htmljson($data)

View File

@@ -80,7 +80,7 @@ foreach ($rrd_list as $i => $rrd) {
$rrd_options .= ' CDEF:' . $g_defname . $i . 'min=' . $rrd['ds'] . $i . 'min,' . $multiplier . ',*'; $rrd_options .= ' CDEF:' . $g_defname . $i . 'min=' . $rrd['ds'] . $i . 'min,' . $multiplier . ',*';
$rrd_options .= ' CDEF:' . $g_defname . $i . 'max=' . $rrd['ds'] . $i . 'max,' . $multiplier . ',*'; $rrd_options .= ' CDEF:' . $g_defname . $i . 'max=' . $rrd['ds'] . $i . 'max,' . $multiplier . ',*';
// If we've been passed a divider (divisor!) we make a CDEF for it. // If we've been passed a divider (divisor!) we make a CDEF for it.
} elseif (is_numeric($divider)) { } elseif (is_numeric($divider)) {
$g_defname = $rrd['ds'] . '_cdef'; $g_defname = $rrd['ds'] . '_cdef';
$rrd_options .= ' CDEF:' . $g_defname . $i . '=' . $rrd['ds'] . $i . ',' . $divider . ',/'; $rrd_options .= ' CDEF:' . $g_defname . $i . '=' . $rrd['ds'] . $i . ',' . $divider . ',/';

View File

@@ -1,6 +1,5 @@
<?php <?php
use App\Models\Device;
use App\Models\Port; use App\Models\Port;
use App\Models\PortAdsl; use App\Models\PortAdsl;
use App\Models\PortVdsl; use App\Models\PortVdsl;

View File

@@ -35,7 +35,7 @@ function bulk_sensor_snmpget($device, $sensors)
} }
/** /**
* @param $device * @param $device
* @param string $type type/class of sensor * @param string $type type/class of sensor
* @return array * @return array
*/ */
@@ -131,8 +131,8 @@ function poll_sensor($device, $class)
}//end poll_sensor() }//end poll_sensor()
/** /**
* @param $device * @param $device
* @param $all_sensors * @param $all_sensors
*/ */
function record_sensor_data($device, $all_sensors) function record_sensor_data($device, $all_sensors)
{ {

View File

@@ -220,7 +220,7 @@ function ipmiSensorName($hardwareId, $sensorIpmi)
} }
/** /**
* @param $descr * @param $descr
* @return int * @return int
*/ */
function get_nagios_state($descr) function get_nagios_state($descr)
@@ -247,7 +247,7 @@ function get_nagios_state($descr)
} }
/** /**
* @param $state * @param $state
* @return int * @return int
*/ */
function apc_relay_state($state) function apc_relay_state($state)

View File

@@ -381,7 +381,7 @@ function snmp_getnext_multi($device, $oids, $options = '-OQUs', $mib = null, $mi
}//end snmp_getnext_multi() }//end snmp_getnext_multi()
/** /**
* @param $device * @param $device
* @return bool * @return bool
*/ */
function snmp_check($device) function snmp_check($device)
@@ -909,8 +909,8 @@ function snmp_translate($oid, $mib = 'ALL', $mibdir = null, $options = null, $de
* (eg. PolicyIndex/ObjectsIndex in CISCO-CLASS-BASED-QOS-MIB). * (eg. PolicyIndex/ObjectsIndex in CISCO-CLASS-BASED-QOS-MIB).
* The resulting array allows us to easily access the top level index we want and iterate over the data from there. * The resulting array allows us to easily access the top level index we want and iterate over the data from there.
* *
* @param $device * @param $device
* @param $OID * @param $OID
* @param int $indexes * @param int $indexes
* *
* @internal param $string * @internal param $string
@@ -963,7 +963,7 @@ function snmpwalk_array_num($device, $oid, $indexes = 1)
} }
/** /**
* @param $device * @param $device
* @return bool * @return bool
*/ */
function get_device_max_repeaters($device) function get_device_max_repeaters($device)

View File

@@ -6,7 +6,6 @@ use App\Http\Controllers\AlertTransportController;
use App\Http\Controllers\Auth\SocialiteController; use App\Http\Controllers\Auth\SocialiteController;
use App\Http\Controllers\PushNotificationController; use App\Http\Controllers\PushNotificationController;
use App\Http\Controllers\ValidateController; use App\Http\Controllers\ValidateController;
use App\Http\Controllers\Widgets;
use App\Http\Middleware\AuthenticateGraph; use App\Http\Middleware\AuthenticateGraph;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;

View File

@@ -30,7 +30,6 @@ use App\Models\Device;
use App\Models\Port; use App\Models\Port;
use App\Models\User; use App\Models\User;
use LibreNMS\Tests\TestCase; use LibreNMS\Tests\TestCase;
use Mockery\Mock;
class PermissionsTest extends TestCase class PermissionsTest extends TestCase
{ {