Smile-SA/elasticsuite

View on GitHub

Showing 620 of 1,375 total issues

Function handleNestedField has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    protected function handleNestedField($eventData, $field)
    {
        $fieldPath = $field->getNestedPath();
        if ($eventData->hasData($fieldPath)) {
            $fieldName = $field->getNestedFieldName();

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function addChildrenQueries has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    private function addChildrenQueries($query, CategoryInterface $category, $excludedCategories = []): QueryInterface
    {
        $childrenCategories    = $this->getChildrenCategories($category, $excludedCategories);
        $childrenCategoriesIds = [];

Severity: Minor
Found in src/module-elasticsuite-virtual-category/Model/Rule.php - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Consider simplifying this complex logical expression.
Open

            if (!options.childList && !options.attributes && !options.characterData ||

                // 1.2
                options.attributeOldValue && !options.attributes ||

Severity: Critical
Found in src/module-elasticsuite-core/view/base/web/js/MutationObserver.js - About 2 hrs to fix

    Function json2html has 65 lines of code (exceeds 40 allowed). Consider refactoring.
    Open

      function json2html(json, options) {
        var html = '';
        if (typeof json === 'string') {
          // Escape tags and quotes
          json = json

      Method _initElement has 65 lines of code (exceeds 40 allowed). Consider refactoring.
      Open

          protected function _initElement(
              \Magento\Config\Model\Config\Structure\Element\Field $field,
              \Magento\Framework\Data\Form\Element\Fieldset $fieldset,
              $path,
              $fieldPrefix = '',

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

                Context $context,
                Registry $registry,
                FormFactory             $formFactory,
                TimezoneInterface       $localeDate,
                CombineConditionFactory $combineConditionsFactory,
        Severity: Major
        Found in src/module-elasticsuite-virtual-category/Model/Rule.php - About 2 hrs to fix

          Function _refreshValue has 64 lines of code (exceeds 40 allowed). Consider refactoring.
          Open

                  _refreshValue: function () {
                      var lastValPercent, valPercent, value, valueMin, valueMax,
                          oRange = this.options.range,
                          o = this.options,
                          that = this,
          Severity: Major
          Found in src/module-elasticsuite-catalog/view/frontend/web/js/slider.js - About 1 hr to fix

            Function _drawColorBox has 63 lines of code (exceeds 40 allowed). Consider refactoring.
            Open

                    _drawColorBox(ctx, pt, i, rtlHelper, options) {
                        const me = this;
                        const labelColors = me.labelColors[i];
                        const labelPointStyle = me.labelPointStyles[i];
                        const {boxHeight, boxWidth} = options;
            Severity: Major
            Found in src/module-elasticsuite-core/view/adminhtml/web/js/lib/chart.js - About 1 hr to fix

              Function getSearchQuery has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getSearchQuery(ProductCondition $productCondition)
                  {
                      $query = null;
              
                      $query = $this->getSpecialAttributesSearchQuery($productCondition);

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function applyPostFilters has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function applyPostFilters(array $filters = [], array $indices = [])
                  {
                      $filtered = [];
              
                      foreach ($indices as $index) {
              Severity: Minor
              Found in src/module-elasticsuite-indices/Model/Index/Collection.php - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function saveIndex has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function saveIndex($dimensions, \Traversable $documents)
                  {
                      foreach ($dimensions as $dimension) {
                          $storeId   = $dimension->getValue();
              
              
              Severity: Minor
              Found in src/module-elasticsuite-core/Indexer/GenericIndexerHandler.php - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function getLanguageStemmers has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function getLanguageStemmers(\DOMXPath $xpath, \DomNode $rootNode, $defaultStemmer = null)
                  {
                      $stemmers = [];
              
                      $searchPath = sprintf("./%s", self::STEMMER_TYPE_NODE);
              Severity: Minor
              Found in src/module-elasticsuite-core/Index/Analysis/Config/Converter.php - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function getItems has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getItems()
                  {
                      if ($this->items === null) {
                          $this->items = [];
              
              

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function loadVariationByFallback has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function loadVariationByFallback(Product $parentProduct, array $attributes)
                  {
                      $variation = false;
              
                      if ($this->isProductHasSwatch($parentProduct) && $parentProduct->getDocumentSource() !== null) {
              Severity: Minor
              Found in src/module-elasticsuite-swatches/Helper/Swatches.php - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function handleEvent has 62 lines of code (exceeds 40 allowed). Consider refactoring.
              Open

                      handleEvent: function(e) {
                          // Stop propagation since we are managing the propagation manually.
                          // This means that other mutation events on the page will not work
                          // correctly but that is by design.
                          e.stopImmediatePropagation();
              Severity: Major
              Found in src/module-elasticsuite-core/view/base/web/js/MutationObserver.js - About 1 hr to fix

                Method build has 61 lines of code (exceeds 40 allowed). Consider refactoring.
                Open

                    public function build(AggregationInterface $aggregation, ?int $storeId): array
                    {
                        $prefix = Mapping::OPTION_TEXT_PREFIX . '_';
                        $result = [];
                
                

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

                          \Magento\Framework\Data\Collection\EntityFactory $entityFactory,
                          \Psr\Log\LoggerInterface $logger,
                          \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
                          \Magento\Framework\Event\ManagerInterface $eventManager,
                          \Magento\Eav\Model\Config $eavConfig,

                    Function getPropertyConfig has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        private function getPropertyConfig($analyzer = self::ANALYZER_UNTOUCHED): array
                        {
                            $fieldMapping = ['type' => $this->getType()];
                    
                            switch ($this->getType()) {
                    Severity: Minor
                    Found in src/module-elasticsuite-core/Index/Mapping/Field.php - About 1 hr to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    Function indexEvents has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function indexEvents($events)
                        {
                            $sessionIdsByStore = $this->getSessionIdsByStore($events);
                            $bulk              = $this->indexOperation->createBulk();
                            $indices           = [];
                    Severity: Minor
                    Found in src/module-elasticsuite-tracker/Model/SessionIndex.php - About 1 hr to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

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

                            \Magento\Rule\Model\Condition\Context $context,
                            \Magento\Backend\Helper\Data $backendData,
                            \Magento\Eav\Model\Config $config,
                            \Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\AttributeList $attributeList,
                            \Smile\ElasticsuiteCatalogRule\Model\Rule\Condition\Product\QueryBuilder $queryBuilder,
                      Severity
                      Category
                      Status
                      Source
                      Language