More static analysis

This commit is contained in:
Lance Pioch 2024-03-16 14:26:08 -04:00
parent 095bc89aee
commit 41c3f1336a
6 changed files with 11 additions and 14 deletions

View File

@ -97,7 +97,7 @@ class BulkPowerActionCommand extends Command
$instance->whereIn('id', $servers)->orWhereIn('node_id', $nodes); $instance->whereIn('id', $servers)->orWhereIn('node_id', $nodes);
} elseif (empty($nodes) && !empty($servers)) { } elseif (empty($nodes) && !empty($servers)) {
$instance->whereIn('id', $servers); $instance->whereIn('id', $servers);
} elseif (!empty($nodes) && empty($servers)) { } elseif (!empty($nodes)) {
$instance->whereIn('node_id', $nodes); $instance->whereIn('node_id', $nodes);
} }

View File

@ -55,10 +55,8 @@ class LoginCheckpointController extends AbstractLoginController
$this->sendFailedLoginResponse($request); $this->sendFailedLoginResponse($request);
} }
try { $user = User::query()->find($details['user_id']);
/** @var \App\Models\User $user */ if (!$user) {
$user = User::query()->findOrFail($details['user_id']);
} catch (ModelNotFoundException) {
$this->sendFailedLoginResponse($request, null, self::TOKEN_EXPIRED_MESSAGE); $this->sendFailedLoginResponse($request, null, self::TOKEN_EXPIRED_MESSAGE);
} }

View File

@ -45,12 +45,9 @@ class LoginController extends AbstractLoginController
$this->sendLockoutResponse($request); $this->sendLockoutResponse($request);
} }
try { $username = $request->input('user');
$username = $request->input('user'); $user = User::query()->where($this->getField($username), $username)->first();
if (!$user) {
/** @var \App\Models\User $user */
$user = User::query()->where($this->getField($username), $username)->firstOrFail();
} catch (ModelNotFoundException) {
$this->sendFailedLoginResponse($request); $this->sendFailedLoginResponse($request);
} }

View File

@ -60,6 +60,9 @@ class Node extends Model
*/ */
protected $hidden = ['daemon_token_id', 'daemon_token']; protected $hidden = ['daemon_token_id', 'daemon_token'];
private int $sum_memory;
private int $sum_disk;
/** /**
* Cast values to correct type. * Cast values to correct type.
*/ */

View File

@ -54,8 +54,7 @@ class AssignmentService
$underlying = gethostbyname($data['allocation_ip']); $underlying = gethostbyname($data['allocation_ip']);
$parsed = Network::parse($underlying); $parsed = Network::parse($underlying);
} catch (\Exception $exception) { } catch (\Exception $exception) {
/* @noinspection PhpUndefinedVariableInspection */ throw new DisplayException("Could not parse provided allocation IP address ({$data['allocation_ip']}): {$exception->getMessage()}", $exception);
throw new DisplayException("Could not parse provided allocation IP address ({$underlying}): {$exception->getMessage()}", $exception);
} }
$this->connection->beginTransaction(); $this->connection->beginTransaction();

View File

@ -7,7 +7,7 @@ parameters:
- app/ - app/
# Level 9 is the highest level # Level 9 is the highest level
level: 0 level: 1
# ignoreErrors: # ignoreErrors:
# - '#PHPDoc tag @var#' # - '#PHPDoc tag @var#'