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);
} elseif (empty($nodes) && !empty($servers)) {
$instance->whereIn('id', $servers);
} elseif (!empty($nodes) && empty($servers)) {
} elseif (!empty($nodes)) {
$instance->whereIn('node_id', $nodes);
}

View File

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

View File

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

View File

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

View File

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

View File

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