From 77f47fcbe03b7fc86273201a725b547aa598b117 Mon Sep 17 00:00:00 2001 From: markus-moser Date: Wed, 22 May 2024 17:11:57 +0200 Subject: [PATCH] SonarCloud fixes --- .../Compiler/SearchModifierHandlerPass.php | 2 +- src/Repository/IndexQueueRepository.php | 2 +- .../Asset/FieldDefinitionAdapter/AbstractAdapter.php | 6 ++---- src/SearchIndexAdapter/OpenSearch/IndexStatsService.php | 2 +- src/SearchIndexAdapter/OpenSearch/PathService.php | 4 ++-- .../OpenSearch/QueryLanguage/SubQueriesProcessor.php | 2 +- .../OpenSearch/Search/SearchExecutionService.php | 6 ++++-- src/Service/SearchIndex/IndexQueue/QueueMessageService.php | 2 +- src/Traits/ElementNormalizerTrait.php | 3 ++- 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/DependencyInjection/Compiler/SearchModifierHandlerPass.php b/src/DependencyInjection/Compiler/SearchModifierHandlerPass.php index 0db8db30..a44b5124 100644 --- a/src/DependencyInjection/Compiler/SearchModifierHandlerPass.php +++ b/src/DependencyInjection/Compiler/SearchModifierHandlerPass.php @@ -198,7 +198,7 @@ private function checkArgumentInstanceOf( || in_array($classOrInterface, class_implements($type->getName()), true) ); - } catch(Exception) { + } catch (Exception) { return false; } } diff --git a/src/Repository/IndexQueueRepository.php b/src/Repository/IndexQueueRepository.php index ab27dbd3..894623a0 100644 --- a/src/Repository/IndexQueueRepository.php +++ b/src/Repository/IndexQueueRepository.php @@ -56,7 +56,7 @@ public function dispatchableItemExists(): bool ->getOneOrNullResult(); return $result !== null; - } catch(NonUniqueResultException) { + } catch (NonUniqueResultException) { return true; } } diff --git a/src/SearchIndexAdapter/OpenSearch/Asset/FieldDefinitionAdapter/AbstractAdapter.php b/src/SearchIndexAdapter/OpenSearch/Asset/FieldDefinitionAdapter/AbstractAdapter.php index 6b0f0daa..cb239513 100644 --- a/src/SearchIndexAdapter/OpenSearch/Asset/FieldDefinitionAdapter/AbstractAdapter.php +++ b/src/SearchIndexAdapter/OpenSearch/Asset/FieldDefinitionAdapter/AbstractAdapter.php @@ -121,13 +121,11 @@ protected function validateArray(array $value): void protected function getSearchFilterFieldPath(AssetMetaDataFilter|AssetMetaDataAggregation $filter): string { - return implode('.', - [ + return implode('.', [ FieldCategory::STANDARD_FIELDS->value, $filter->getName(), $filter->getLanguage() ?? MappingProperty::NOT_LOCALIZED_KEY, - ] - ); + ]); } /** diff --git a/src/SearchIndexAdapter/OpenSearch/IndexStatsService.php b/src/SearchIndexAdapter/OpenSearch/IndexStatsService.php index c7a44be9..dcaa71d4 100644 --- a/src/SearchIndexAdapter/OpenSearch/IndexStatsService.php +++ b/src/SearchIndexAdapter/OpenSearch/IndexStatsService.php @@ -62,7 +62,7 @@ private function countIndexQueueEntries(): int { try { return $this->indexQueueRepository->countIndexQueueEntries(); - } catch(Exception $e) { + } catch (Exception $e) { $this->logger->error('Error while counting index queue entries: '. $e->getMessage()); } diff --git a/src/SearchIndexAdapter/OpenSearch/PathService.php b/src/SearchIndexAdapter/OpenSearch/PathService.php index 0e496d21..4a7b562d 100644 --- a/src/SearchIndexAdapter/OpenSearch/PathService.php +++ b/src/SearchIndexAdapter/OpenSearch/PathService.php @@ -70,8 +70,8 @@ public function rewriteChildrenIndexPaths(ElementInterface $element): void if ($countResult > $this->searchIndexConfigService->getMaxSynchronousChildrenRenameLimit()) { $msg = sprintf( - 'Direct rewrite of children paths in OpenSearch was skipped as more than %s - items need an update (%s items). + 'Direct rewrite of children paths in OpenSearch was skipped as more than %s + items need an update (%s items). The index will be updated asynchronously via index update queue command cronjob.', $this->searchIndexConfigService->getMaxSynchronousChildrenRenameLimit(), $countResult diff --git a/src/SearchIndexAdapter/OpenSearch/QueryLanguage/SubQueriesProcessor.php b/src/SearchIndexAdapter/OpenSearch/QueryLanguage/SubQueriesProcessor.php index 9062e28b..4ea62b81 100644 --- a/src/SearchIndexAdapter/OpenSearch/QueryLanguage/SubQueriesProcessor.php +++ b/src/SearchIndexAdapter/OpenSearch/QueryLanguage/SubQueriesProcessor.php @@ -65,7 +65,7 @@ public function processSubQueries( $subQuery->getTargetQuery(), $indexEntity, ); - } catch(ParsingException $e) { + } catch (ParsingException $e) { throw new ParsingException( $originalQuery, $e->getExpected(), diff --git a/src/SearchIndexAdapter/OpenSearch/Search/SearchExecutionService.php b/src/SearchIndexAdapter/OpenSearch/Search/SearchExecutionService.php index 57a29458..dc7e72ee 100644 --- a/src/SearchIndexAdapter/OpenSearch/Search/SearchExecutionService.php +++ b/src/SearchIndexAdapter/OpenSearch/Search/SearchExecutionService.php @@ -75,14 +75,16 @@ public function executeSearch(AdapterSearchInterface $search, string $indexName) throw new ResultWindowTooLargeException( $searchInformation, 'Result window too large: ' . $e->getMessage(), - $e->getCode(), $e + $e->getCode(), + $e ); } throw new SearchFailedException( $searchInformation, 'Search failed: ' . $e->getMessage(), - $e->getCode(), $e + $e->getCode(), + $e ); } diff --git a/src/Service/SearchIndex/IndexQueue/QueueMessageService.php b/src/Service/SearchIndex/IndexQueue/QueueMessageService.php index 7cd42e28..8dcce05b 100644 --- a/src/Service/SearchIndex/IndexQueue/QueueMessageService.php +++ b/src/Service/SearchIndex/IndexQueue/QueueMessageService.php @@ -39,7 +39,7 @@ public function handleMessage( int $entriesCount, int $maxBatchSize ): void { - while(true) { + while (true) { $entries = $this->indexQueueRepository->getUnhandledIndexQueueEntries( true, $maxBatchSize diff --git a/src/Traits/ElementNormalizerTrait.php b/src/Traits/ElementNormalizerTrait.php index 94568478..3d3ac25a 100644 --- a/src/Traits/ElementNormalizerTrait.php +++ b/src/Traits/ElementNormalizerTrait.php @@ -91,7 +91,8 @@ private function getTagsByElement(ElementInterface $element): array $tag = new Tag(); return $tag->getDao()->getTagsForElement( - Service::getElementType($element), $element->getId() + Service::getElementType($element), + $element->getId() ); }