Linting: Fix misc problems (#12675)

This commit is contained in:
Jellyfrog
2021-03-30 00:43:05 +02:00
committed by GitHub
parent 571e1b67bf
commit 6c59f368b0
16 changed files with 29 additions and 18 deletions

View File

@@ -75,7 +75,7 @@ class Alerta extends Transport
var_dump("API '$host' returned Error");
var_dump('Params: ' . $alert_message);
var_dump('Return: ' . $ret);
var_dump('Headers: ' . $headers);
var_dump('Headers: ', $headers);
return 'HTTP Status code ' . $code;
}

View File

@@ -100,7 +100,7 @@ class Hipchat extends Transport
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($code != 200 && $code != 204) {
var_dump("API '$url' returned Error");
var_dump('Params: ' . $message);
//var_dump('Params: ' . $message);
var_dump('Return: ' . $ret);
return 'HTTP Status code ' . $code;

View File

@@ -56,9 +56,7 @@ class Pushbullet extends Transport
$ret = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($code > 201) {
if ($debug) {
var_dump($ret);
}
var_dump($ret);
return 'HTTP Status code ' . $code;
}

View File

@@ -41,7 +41,7 @@ class Eloquent
if (! Laravel::isBooted() && is_null(self::$capsule)) {
$install_dir = realpath(__DIR__ . '/../../');
Dotenv::create($install_dir)->load();
Dotenv::createMutable($install_dir)->load();
$db_config = include $install_dir . '/config/database.php';
$settings = $db_config['connections'][$db_config['default']];

View File

@@ -722,7 +722,9 @@ class IRCBot
$new_config = Config::load();
$this->respond('Reloading configuration & defaults');
if ($new_config != $this->config) {
return $this->__construct();
$this->__construct();
return;
}
} else {
return $this->respond('Permission denied.');
@@ -847,6 +849,7 @@ class IRCBot
$tmp = dbFetchRows('SELECT `hostname` FROM `devices` WHERE status=0');
}
$msg = '';
foreach ($tmp as $db) {
if ($db['hostname']) {
$msg .= ', ' . $db['hostname'];
@@ -916,6 +919,7 @@ class IRCBot
$tmp = dbFetchRows('SELECT `hostname` FROM `devices`');
}
$msg = '';
foreach ($tmp as $device) {
$msg .= ', ' . $device['hostname'];
}
@@ -932,6 +936,11 @@ class IRCBot
{
$params = explode(' ', $params);
$statustype = $params[0];
$d_w = '';
$d_a = '';
$p_w = '';
$p_a = '';
if ($this->user['level'] < 5) {
$d_w = ' WHERE device_id IN (' . implode(',', $this->user['devices']) . ')';
$d_a = ' AND device_id IN (' . implode(',', $this->user['devices']) . ')';

View File

@@ -49,7 +49,7 @@ class Avocent extends OS implements OSDiscovery
} elseif (Str::startsWith($device->sysObjectID, '.1.3.6.1.4.1.10418.26')) {
$avocent_oid = '.1.3.6.1.4.1.10418.26.2.1';
}
if ($avocent_oid) {
if (isset($avocent_oid)) {
$avocent_tmp = snmp_get_multi_oid($this->getDeviceArray(), "$avocent_oid.2.0 $avocent_oid.4.0 $avocent_oid.7.0");
$hardware = explode(' ', $avocent_tmp["$avocent_oid.2.0"] ?? '', 2)[0] ?: null;
$serial = $avocent_tmp["$avocent_oid.4.0"] ?? null;

View File

@@ -94,6 +94,7 @@ class HiveosWireless extends OS implements
{
$ahRadioName = $this->getCacheByIndex('ahIfName', 'AH-INTERFACE-MIB');
$data = snmpwalk_group($this->getDeviceArray(), 'ahRadioChannel', 'AH-INTERFACE-MIB');
$sensors = [];
foreach ($data as $index => $frequency) {
$sensors[] = new WirelessSensor(
'frequency',

View File

@@ -54,6 +54,7 @@ class Lcos extends OS implements
*/
private function strToDecOid($index)
{
$dec_index = [];
for ($i = 0, $j = strlen($index); $i < $j; $i++) {
$dec_index[] = ord($index[$i]);
}

View File

@@ -130,7 +130,7 @@ class Pmp extends OS implements
$tags = compact('rrd_def');
data_update($this->getDeviceArray(), 'canopy-generic-jitter', $tags, $fields);
$this->enableGraph('canopy_generic_jitter');
unset($rrd_filename, $jitter);
unset($rrd_def, $jitter);
}
$multi_get_array = snmp_get_multi($this->getDeviceArray(), ['regCount.0', 'regFailureCount.0'], '-OQU', 'WHISP-APS-MIB');
@@ -149,7 +149,7 @@ class Pmp extends OS implements
$tags = compact('rrd_def');
data_update($this->getDeviceArray(), 'canopy-generic-regCount', $tags, $fields);
$this->enableGraph('canopy_generic_regCount');
unset($rrd_filename, $registered, $failed);
unset($rrd_def, $registered, $failed);
}
$visible = str_replace('"', '', snmp_get($this->getDeviceArray(), '.1.3.6.1.4.1.161.19.3.4.4.7.0', '-Ovqn', ''));
@@ -227,7 +227,7 @@ class Pmp extends OS implements
$tags = compact('rrd_def');
data_update($this->getDeviceArray(), 'canopy-generic-signalHV', $tags, $fields);
$this->enableGraph('canopy_generic_signalHV');
unset($rrd_filename, $vertical, $horizontal, $combined);
unset($rrd_def, $vertical, $horizontal, $combined);
}
$horizontal = str_replace('"', '', snmp_get($this->getDeviceArray(), 'radioDbmHorizontal.0', '-Ovqn', 'WHISP-SM-MIB'));

View File

@@ -21,6 +21,7 @@ class Ruckuswireless extends OS implements
$total_oids = [];
$total = 0;
$index = null;
foreach ($counts as $index => $count) {
$oid = '.1.3.6.1.4.1.25053.1.2.2.1.1.1.1.1.12.' . $index;
$total_oids[] = $oid;
@@ -60,8 +61,7 @@ class Ruckuswireless extends OS implements
$oidconnected,
'ruckuswireless',
++$sensorindex,
'Connected APs',
$count
'Connected APs'
);
array_push($sensors, new WirelessSensor('ap-count', $this->getDeviceId(), $oidtotal, 'ruckuswireless', ++$sensorindex, 'Total APs'));

View File

@@ -34,6 +34,7 @@ class RuckuswirelessSz extends OS implements
$total_oids = [];
$total = 0;
$index = null;
foreach ($counts as $index => $count) {
$oid = '.1.3.6.1.4.1.25053.1.4.2.1.1.1.2.1.12.' . $index;
$total_oids[] = $oid;
@@ -66,6 +67,7 @@ class RuckuswirelessSz extends OS implements
{
$apconnected = $this->getCacheByIndex('ruckusCtrlSystemNodeNumApConnected', 'RUCKUS-CTRL-MIB', '-OQUsb');
$dbindex = 0;
$apstatus = [];
foreach ($apconnected as $index => $connect) {
$oid = '.1.3.6.1.4.1.25053.1.8.1.1.1.1.1.1.19.' . $index;
$apstatus[] = new WirelessSensor(

View File

@@ -50,7 +50,7 @@ class JnxDomLaneAlarmCleared implements SnmptrapHandler
$ifIndex = substr(strrchr($trap->findOid('IF-MIB::ifDescr'), '.'), 1);
$port = $device->ports()->where('ifIndex', $ifIndex)->first();
if (! $port) {
Log::warning("Snmptrap JnxDomLaneAlarmCleared: Could not find port at ifIndex $port->ifIndex for device: " . $device->hostname);
Log::warning("Snmptrap JnxDomLaneAlarmCleared: Could not find port at ifIndex $ifIndex for device: " . $device->hostname);
return;
}

View File

@@ -48,7 +48,7 @@ class JnxDomLaneAlarmSet implements SnmptrapHandler
$ifIndex = substr(strrchr($trap->findOid('IF-MIB::ifDescr'), '.'), 1);
$port = $device->ports()->where('ifIndex', $ifIndex)->first();
if (! $port) {
Log::warning("Snmptrap JnxDomLaneAlarmSet: Could not find port at ifIndex $port->ifIndex for device: " . $device->hostname);
Log::warning("Snmptrap JnxDomLaneAlarmSet: Could not find port at ifIndex $ifIndex for device: " . $device->hostname);
return;
}

View File

@@ -47,7 +47,7 @@ class JnxLdpSesDown implements SnmptrapHandler
$port = $device->ports()->where('ifIndex', $ifIndex)->first();
if (! $port) {
Log::warning("Snmptrap LdpSesDown: Could not find port at ifIndex $port->ifIndex for device: " . $device->hostname);
Log::warning("Snmptrap LdpSesDown: Could not find port at ifIndex $ifIndex for device: " . $device->hostname);
return;
}

View File

@@ -47,7 +47,7 @@ class GetConfigCommand extends LnmsCommand
if (Config::has($setting)) {
$output = Config::get($setting);
if (! is_string($output)) {
$output = var_export($output, 1);
$output = var_export($output, true);
}
$this->line($output);

View File

@@ -146,7 +146,7 @@ class AppServiceProvider extends ServiceProvider
}, __('The :attribute must a valid IP address/network or hostname.'));
Validator::extend('is_regex', function ($attribute, $value) {
return @preg_match($value, null) !== false;
return @preg_match($value, '') !== false;
}, __(':attribute is not a valid regular expression'));
Validator::extend('zero_or_exists', function ($attribute, $value, $parameters, $validator) {