Skip to content

Commit

Permalink
* remove exit() statement that exists from f8939b8, and now being u…
Browse files Browse the repository at this point in the history
…nnecessary due to 8089d16 @ `App\Helper->abortAPI()`

* suppress or fix some violations of phpmd rules
@ be
  • Loading branch information
n0099 committed Sep 15, 2024
1 parent 2766c30 commit fdeea75
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion be/app/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ public static function abortAPI(int $errorCode): never
throw new \InvalidArgumentException('Given error code doesn\'t existed');
}
response()->json(compact('errorCode', 'errorInfo'), $statusCode)->throwResponse();
exit;
}

/**
Expand Down
1 change: 1 addition & 0 deletions be/app/Http/PostsQuery/BaseQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ static function (string $postIDName) use ($result): array {
* @param Collection<int, SubReply> $subReplies
* @phpcs:ignore Generic.Files.LineLength.TooLong
* @return Collection<int, Collection<string, mixed|Collection<int, Collection<string, mixed|Collection<int, Collection<string, mixed>>>>>>
* @SuppressWarnings(PHPMD.CamelCaseParameterName)
*/
public static function nestPostsWithParent(
Collection $threads,
Expand Down
3 changes: 3 additions & 0 deletions be/app/Http/PostsQuery/IndexQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@

class IndexQuery extends BaseQuery
{
/**
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function query(QueryParams $params, ?string $cursor): self

Check warning on line 19 in be/app/Http/PostsQuery/IndexQuery.php

View workflow job for this annotation

GitHub Actions / runs-on (windows-latest) / phpmd

IndexQuery.php: The method query() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10. (CyclomaticComplexity, Code Size Rules)

Check warning on line 19 in be/app/Http/PostsQuery/IndexQuery.php

View workflow job for this annotation

GitHub Actions / runs-on (windows-latest) / phpmd

IndexQuery.php: The method query() has an NPath complexity of 400. The configured NPath complexity threshold is 200. (NPathComplexity, Code Size Rules)
{
/** @var array<string, mixed> $flatParams key by param name */
Expand Down
3 changes: 3 additions & 0 deletions be/app/Http/PostsQuery/QueryParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ protected function getParamsIndexByName(string $name): array
return array_keys(array_filter($this->params, static fn($p) => $p->name === $name));
}

/**
* @SuppressWarnings(PHPMD.ElseExpression)
*/
public function addDefaultValueOnUniqueParams(): void
{
$uniqueParamsDefaultValue = [
Expand Down
9 changes: 3 additions & 6 deletions be/app/Http/PostsQuery/SearchQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,9 @@ private static function applyTextMatchParamOnQuery(
trim("$not LIKE"),
$subParams['matchBy'] === 'implicit' ? "%$keyword%" : $keyword
);
if ($subParams['spaceSplit']) { // split multiple search keyword by space char
foreach (explode(' ', $value) as $splitedKeyword) {
$addMatchKeyword($splitedKeyword);
}
} else {
$addMatchKeyword($value);
// split multiple search keyword by space char when $subParams['spaceSplit'] == true
foreach ($subParams['spaceSplit'] ? explode(' ', $value) : [$value] as $keyword) {
$addMatchKeyword($keyword);
}
});
}
Expand Down

0 comments on commit fdeea75

Please sign in to comment.