Smile-SA/elasticsuite

View on GitHub
src/module-elasticsuite-thesaurus/Model/Index.php

Summary

Maintainability
C
7 hrs
Test Coverage

Showing 9 of 9 total issues

Index has 12 functions (exceeds 10 allowed). Consider refactoring.
Open

class Index
{
/**
* @var string
*/
Severity: Minor
Found in src/module-elasticsuite-thesaurus/Model/Index.php - About 2 hrs to fix

    Function getSynonymRewrites has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    private function getSynonymRewrites($storeId, $queryText, $type, $maxRewrites)
    {
    $indexName = $this->getIndexAlias($storeId);
    $analyzedQueries = $this->getQueryCombinations($storeId, str_replace('-', ' ', $queryText));
    $synonyms = [];
    Severity: Minor
    Found in src/module-elasticsuite-thesaurus/Model/Index.php - About 1 hr to fix

    Function combineSynonyms has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    private function combineSynonyms($queryText, $synonymByPositions, $maxRewrites, $substitutions = 0, $offset = 0)
    {
    $combinations = [];
     
    if (!empty($synonymByPositions) && $substitutions < $maxRewrites) {
    Severity: Minor
    Found in src/module-elasticsuite-thesaurus/Model/Index.php - About 55 mins to fix

    Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    ClientInterface $client,
    IndexSettingsHelper $indexSettingsHelper,
    CacheHelper $cacheHelper,
    ThesaurusConfigFactory $thesaurusConfigFactory,
    ThesaurusCacheConfig $thesaurusCacheConfig
    Severity: Minor
    Found in src/module-elasticsuite-thesaurus/Model/Index.php - About 35 mins to fix

      Method combineSynonyms has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      private function combineSynonyms($queryText, $synonymByPositions, $maxRewrites, $substitutions = 0, $offset = 0)
      Severity: Minor
      Found in src/module-elasticsuite-thesaurus/Model/Index.php - About 35 mins to fix

        Assigning \Smile\ElasticsuiteThesaurus\Config\ThesaurusCacheConfig to property but \Smile\ElasticsuiteThesaurus\Model\Index->thesaurusCacheConfig is \Smile\ElasticsuiteThesaurus\Config\ThesaurusConfig
        Open

        $this->thesaurusCacheConfig = $thesaurusCacheConfig;

        Argument 3 (baseWeight) is float but \Smile\ElasticsuiteThesaurus\Model\Index::getWeightedRewrites() takes int defined at /code/src/module-elasticsuite-thesaurus/Model/Index.php:362
        Open

        $rewrites = $this->getWeightedRewrites($synonymRewrites, $config->getSynonymWeightDivider(), $originalBoost);

        Returning type \Smile\ElasticsuiteCore\Api\Search\Request\Container\RelevanceConfigurationInterface but getConfig() is declared to return \Smile\ElasticsuiteThesaurus\Config\ThesaurusConfig
        Open

        return $this->thesaurusConfigFactory->create($storeId, $containerName);

        Similar blocks of code found in 6 locations. Consider refactoring.
        Open

        public function __construct(
        ClientInterface $client,
        IndexSettingsHelper $indexSettingsHelper,
        CacheHelper $cacheHelper,
        ThesaurusConfigFactory $thesaurusConfigFactory,
        Severity: Major
        Found in src/module-elasticsuite-thesaurus/Model/Index.php and 5 other locations - About 1 hr to fix
        src/module-elasticsuite-catalog/Plugin/Ui/Category/Form/DataProviderPlugin.php on lines 77..89
        src/module-elasticsuite-core/Model/DataProvider/Suggestions.php on lines 76..88
        src/module-elasticsuite-core/Model/Search/Request/RelevanceConfig/Reader/ContainerStore.php on lines 66..78
        src/module-elasticsuite-core/Search/Request/SortOrder/SortOrderBuilder.php on lines 69..81
        src/module-elasticsuite-virtual-category/Controller/Router.php on lines 73..85
        Category
        Status