Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/Console/Commands/CheckKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public function handle(): int
// so we generate a random key ourselves.
echo Str::password(32, true, true, false) . PHP_EOL;
return 1;
} else {
return 0;
}
return 0;
}
}
5 changes: 2 additions & 3 deletions app/Console/Commands/ValidateXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,8 @@ public function handle(): int
} elseif ($has_skipped) {
$this->error('FAILED: Some XML file checks were skipped!');
return Command::FAILURE;
} else {
$this->line('SUCCESS: All XML file checks passed.');
return Command::SUCCESS;
}
$this->line('SUCCESS: All XML file checks passed.');
return Command::SUCCESS;
}
}
2 changes: 1 addition & 1 deletion app/GraphQL/Scalars/NonNegativeIntegerMilliseconds.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function parseValue(mixed $value): int
*/
public function parseLiteral(Node $valueNode, ?array $variables = null): float
{
if (!($valueNode instanceof IntValueNode)) {
if (!$valueNode instanceof IntValueNode) {
throw new Error("Query error: Can only parse Integers, got {$valueNode->kind}.", $valueNode);
}

Expand Down
2 changes: 1 addition & 1 deletion app/GraphQL/Scalars/NonNegativeSeconds.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function parseValue(mixed $value): float
*/
public function parseLiteral(Node $valueNode, ?array $variables = null): float
{
if (!($valueNode instanceof FloatValueNode)) {
if (!$valueNode instanceof FloatValueNode) {
throw new Error("Query error: Can only parse Floats, got {$valueNode->kind}.", $valueNode);
}

Expand Down
2 changes: 1 addition & 1 deletion app/GraphQL/Scalars/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function parseValue(mixed $value): string
*/
public function parseLiteral(Node $valueNode, ?array $variables = null): string
{
if (!($valueNode instanceof StringValueNode)) {
if (!$valueNode instanceof StringValueNode) {
throw new Error("Query error: Can only parse Strings, got {$valueNode->kind}.", $valueNode);
}

Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ public function credentials(Request $request): array
'password' => $request->post('password'),
'fallback' => $this->traitCredentials($request),
];
} else {
return $this->traitCredentials($request);
}
return $this->traitCredentials($request);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Controllers/ManageMeasurementsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ public function apiDelete(): JsonResponse

if ($deleted) {
return response()->json();
} else {
return response()->json([], 404);
}
return response()->json([], 404);
}
}
12 changes: 4 additions & 8 deletions app/Http/Controllers/RemoteProcessingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ public function getSubmissionFile(): Response
$filename = Storage::path('inprogress') . '/' . basename(request()->string('filename'));
if (!is_readable($filename)) {
return response('Not found', Response::HTTP_NOT_FOUND);
} else {
return response()->file($filename);
}
return response()->file($filename);
}

/**
Expand Down Expand Up @@ -65,19 +64,16 @@ public function deleteSubmissionFile(): Response
// Delete the file.
if (Storage::delete($filename)) {
return response('OK', Response::HTTP_OK);
} else {
return response('Deletion failed', Response::HTTP_INTERNAL_SERVER_ERROR);
}
return response('Deletion failed', Response::HTTP_INTERNAL_SERVER_ERROR);
} elseif (request()->has('dest')) {
// Rename the file.
if (Storage::move($filename, request()->string('dest'))) {
return response('OK', Response::HTTP_OK);
} else {
return response('Rename failed', Response::HTTP_INTERNAL_SERVER_ERROR);
}
} else {
throw new Exception('Invalid request.');
return response('Rename failed', Response::HTTP_INTERNAL_SERVER_ERROR);
}
throw new Exception('Invalid request.');
}

/**
Expand Down
13 changes: 6 additions & 7 deletions app/Http/Controllers/ViewTestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,13 @@ public function fetchPageContent(): JsonResponse|StreamedResponse
$response = $controller->getResponse();
if ($controller->JSONEncodeResponse) {
return response()->json(cast_data_for_JSON($response));
} else {
$headers = [
'Content-Type' => 'text/csv',
];
return response()->streamDownload(function () use ($response): void {
echo $response;
}, 'test-export.csv', $headers);
}
$headers = [
'Content-Type' => 'text/csv',
];
return response()->streamDownload(function () use ($response): void {
echo $response;
}, 'test-export.csv', $headers);
}

/**
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Submission/Handlers/AbstractXmlHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,8 @@ protected function currentPathMatches(string $path): bool
continue;
} elseif (strtoupper($path[$i]) === strtoupper((string) $this->stack->at($i))) { // Match the specified string
continue;
} else {
return false;
}
return false;
}
return true;
}
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Submission/Handlers/BazelJSONHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -749,9 +749,8 @@ public function getBuild(): Build
$build = new Build();
$build->Id = array_values($this->Builds)[0]->GetParentId();
return $build;
} else {
return array_values($this->Builds)[0];
}
return array_values($this->Builds)[0];
}

private function RecordError($build_error, $type, $subproject_name): void
Expand Down
21 changes: 10 additions & 11 deletions app/Http/Submission/Handlers/BuildHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ public function endElement($parser, $name): void
if (!$hasLabel) {
$label = $factory->create(Label::class);
$label->Text = $this->SubProjectName;
if (!($this->Error instanceof BuildFailure)) {
if (!$this->Error instanceof BuildFailure) {
throw new RuntimeException('Field "Error" is not instance of BuildFailure.');
}
$this->Error->AddLabel($label);
Expand Down Expand Up @@ -568,7 +568,7 @@ public function text($parser, $data): void
break;
}
} elseif ($this->getParent() === 'ACTION') {
if (!($this->Error instanceof BuildFailure)) {
if (!$this->Error instanceof BuildFailure) {
throw new RuntimeException('Field "Error" is not instance of BuildFailure.');
}

Expand All @@ -590,7 +590,7 @@ public function text($parser, $data): void
break;
}
} elseif ($this->getParent() === 'COMMAND') {
if (!($this->Error instanceof BuildFailure)) {
if (!$this->Error instanceof BuildFailure) {
throw new RuntimeException('Field "Error" is not instance of BuildFailure.');
}

Expand All @@ -603,7 +603,7 @@ public function text($parser, $data): void
break;
}
} elseif ($this->getParent() === 'RESULT') {
if (!($this->Error instanceof BuildFailure)) {
if (!$this->Error instanceof BuildFailure) {
throw new RuntimeException('Field "Error" is not instance of BuildFailure.');
}

Expand All @@ -621,29 +621,29 @@ public function text($parser, $data): void
break;
}
} elseif ($element === 'BUILDLOGLINE') {
if (!($this->Error instanceof BuildError)) {
if (!$this->Error instanceof BuildError) {
throw new RuntimeException('Field "Error" is not instance of BuildError.');
}
$this->Error->LogLine .= $data;
} elseif ($element === 'TEXT') {
if (!($this->Error instanceof BuildError)) {
if (!$this->Error instanceof BuildError) {
throw new RuntimeException('Field "Error" is not instance of BuildError.');
}
$this->Error->Text .= $data;
} elseif ($element === 'SOURCEFILE') {
$this->Error->SourceFile .= $data;
} elseif ($element === 'SOURCELINENUMBER') {
if (!($this->Error instanceof BuildError)) {
if (!$this->Error instanceof BuildError) {
throw new RuntimeException('Field "Error" is not instance of BuildError.');
}
$this->Error->SourceLine .= $data;
} elseif ($element === 'PRECONTEXT') {
if (!($this->Error instanceof BuildError)) {
if (!$this->Error instanceof BuildError) {
throw new RuntimeException('Field "Error" is not instance of BuildError.');
}
$this->Error->PreContext .= $data;
} elseif ($element === 'POSTCONTEXT') {
if (!($this->Error instanceof BuildError)) {
if (!$this->Error instanceof BuildError) {
throw new RuntimeException('Field "Error" is not instance of BuildError.');
}
$this->Error->PostContext .= $data;
Expand Down Expand Up @@ -705,9 +705,8 @@ public function getBuild(): Build
$build = new Build();
$build->Id = array_values($this->Builds)[0]->GetParentId();
return $build;
} else {
return array_values($this->Builds)[0];
}
return array_values($this->Builds)[0];
}

public function GetBuildCollection(): BuildCollection
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Submission/Handlers/ConfigureHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,8 @@ public function getBuild(): Build
$build = new Build();
$build->Id = array_values($this->Builds)[0]->GetParentId();
return $build;
} else {
return array_values($this->Builds)[0];
}
return array_values($this->Builds)[0];
}

public function GetBuildCollection(): BuildCollection
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Submission/Handlers/DynamicAnalysisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,8 @@ public function getBuild(): Build
$build = new Build();
$build->Id = array_values($this->Builds)[0]->GetParentId();
return $build;
} else {
return array_values($this->Builds)[0];
}
return array_values($this->Builds)[0];
}

public function GetBuildCollection(): BuildCollection
Expand Down
3 changes: 1 addition & 2 deletions app/Http/Submission/Handlers/TestingHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,8 @@ public function getBuild(): Build
$build = new Build();
$build->Id = array_values($this->Builds)[0]->GetParentId();
return $build;
} else {
return array_values($this->Builds)[0];
}
return array_values($this->Builds)[0];
}

public function GetBuildCollection(): BuildCollection
Expand Down
57 changes: 26 additions & 31 deletions app/Jobs/ProcessSubmission.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ private function renameSubmissionFile($src, $dst): bool
'filename' => $src,
'dest' => $dst,
])->ok();
} else {
return Storage::move($src, $dst);
}
return Storage::move($src, $dst);
}

private function deleteSubmissionFile($filename): bool
Expand All @@ -100,9 +99,8 @@ private function deleteSubmissionFile($filename): bool
return Http::withToken($app_key)->delete(url('/api/internal/deleteSubmissionFile'), [
'filename' => $filename,
])->ok();
} else {
return Storage::delete($filename);
}
return Storage::delete($filename);
}

private function requeueSubmissionFile($buildid): bool
Expand All @@ -121,27 +119,26 @@ private function requeueSubmissionFile($buildid): bool
$this->localFilename = '';
}
return $response->ok();
} else {
// Increment retry count.
$retry_handler = new RetryHandler("inprogress/{$this->filename}");
$retry_handler->increment();

// Move file back to inbox.
Storage::move("inprogress/{$this->filename}", "inbox/{$this->filename}");

// Requeue the file with exponential backoff.
PendingSubmissions::where('buildid', $this->buildid)->increment('numfiles');
$delay = ((int) config('cdash.retry_base')) ** $retry_handler->Retries;
if (config('queue.default') === 'sqs-fifo') {
// Special handling for sqs-fifo, which does not support per-message delays.
sleep(10);
self::dispatch($this->filename, $this->projectid, $buildid, $this->expected_md5);
} else {
self::dispatch($this->filename, $this->projectid, $buildid, $this->expected_md5)->delay(now()->addSeconds($delay));
}
}
// Increment retry count.
$retry_handler = new RetryHandler("inprogress/{$this->filename}");
$retry_handler->increment();

// Move file back to inbox.
Storage::move("inprogress/{$this->filename}", "inbox/{$this->filename}");

return true;
// Requeue the file with exponential backoff.
PendingSubmissions::where('buildid', $this->buildid)->increment('numfiles');
$delay = ((int) config('cdash.retry_base')) ** $retry_handler->Retries;
if (config('queue.default') === 'sqs-fifo') {
// Special handling for sqs-fifo, which does not support per-message delays.
sleep(10);
self::dispatch($this->filename, $this->projectid, $buildid, $this->expected_md5);
} else {
self::dispatch($this->filename, $this->projectid, $buildid, $this->expected_md5)->delay(now()->addSeconds($delay));
}

return true;
}

/**
Expand Down Expand Up @@ -306,12 +303,11 @@ private function getRemoteSubmissionFileHandle($filename)
}

return fopen($this->localFilename, 'r');
} else {
// Log the status code and requested filename.
// (404 status means it's already been processed).
Log::warning('Failed to retrieve a file handle from filename ' . $filename . '(' . $response->status() . ')');
return false;
}
// Log the status code and requested filename.
// (404 status means it's already been processed).
Log::warning('Failed to retrieve a file handle from filename ' . $filename . '(' . $response->status() . ')');
return false;
}

private function getSubmissionFileHandle($filename)
Expand All @@ -320,10 +316,9 @@ private function getSubmissionFileHandle($filename)
return $this->getRemoteSubmissionFileHandle($filename);
} elseif (Storage::exists($filename)) {
return Storage::readStream($filename);
} else {
Log::error('Failed to get a file handle for submission (was type ' . gettype($filename) . ')');
return false;
}
Log::error('Failed to get a file handle for submission (was type ' . gettype($filename) . ')');
return false;
}

/** Determine the descriptive filename for a submission file. */
Expand Down
2 changes: 1 addition & 1 deletion app/Ldap/Rules/FilterRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function passes(LdapRecord $user, ?Eloquent $model = null): bool

$filter = (string) $filter;

if (!($model instanceof User)) {
if (!$model instanceof User) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function handle(Registered $event): void
/** @var User|MustVerifyEmail $user */
$user = $event->user;

if (!($user instanceof MustVerifyEmail)) {
if (!$user instanceof MustVerifyEmail) {
return;
}

Expand Down
7 changes: 3 additions & 4 deletions app/Models/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,10 @@ public function scopeAdministeredByUser(Builder $query): void

if ($user !== null && $user->admin) {
return;
} else {
$query->whereHas('administrators', function ($subquery) use ($user): void {
$subquery->where('users.id', $user?->id);
});
}
$query->whereHas('administrators', function ($subquery) use ($user): void {
$subquery->where('users.id', $user?->id);
});
}

/**
Expand Down
Loading