Smile-SA/elasticsuite

View on GitHub
src/module-elasticsuite-core/Index/Analysis/Config/Converter.php

Summary

Maintainability
D
1 day
Test Coverage

File Converter.php has 301 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
Severity: Minor
Found in src/module-elasticsuite-core/Index/Analysis/Config/Converter.php - About 3 hrs to fix

    Converter has 11 functions (exceeds 10 allowed). Consider refactoring.
    Open

    class Converter implements \Magento\Framework\Config\ConverterInterface
    {
        const ROOT_NODE_NAME             = 'analysis';
        const CHAR_FILTER_TYPE_ROOT_NODE = 'char_filters';
        const CHAR_FILTER_TYPE_NODE      = 'char_filter';
    Severity: Minor
    Found in src/module-elasticsuite-core/Index/Analysis/Config/Converter.php - About 2 hrs to fix

      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 getAllDefaultLanguageStemmers has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          private function getAllDefaultLanguageStemmers(\DOMXPath $xpath)
          {
              $defaultStemmers = [];
      
              $filterPath = "@type='stemmer' and @name='stemmer'";
      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

      Method getLanguageConfiguration has 51 lines of code (exceeds 40 allowed). Consider refactoring.
      Open

          private function getLanguageConfiguration(\DOMXPath $xpath, $language, array $defaultConfig)
          {
              $languageCharFilters = $this->parseFilters(
                  $xpath,
                  self::CHAR_FILTER_TYPE_ROOT_NODE,
      Severity: Major
      Found in src/module-elasticsuite-core/Index/Analysis/Config/Converter.php - About 1 hr to fix

        Method parseAnalyzers has 43 lines of code (exceeds 40 allowed). Consider refactoring.
        Open

            private function parseAnalyzers(
                \DOMXPath $xpath,
                array $availableCharFilters,
                array $availableFilters,
                $language = self::LANGUAGE_DEFAULT,
        Severity: Minor
        Found in src/module-elasticsuite-core/Index/Analysis/Config/Converter.php - About 1 hr to fix

          Function parseFilters has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              private function parseFilters(\DOMXPath $xpath, $rootNodeName, $nodeName, $language = self::LANGUAGE_DEFAULT)
              {
                  $filters = [];
                  $languagePath = sprintf("[@language='%s']", $language);
                  $searchPath   = sprintf("/%s/%s/%s%s", self::ROOT_NODE_NAME, $rootNodeName, $nodeName, $languagePath);
          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

          Method parseAnalyzers has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  \DOMXPath $xpath,
                  array $availableCharFilters,
                  array $availableFilters,
                  $language = self::LANGUAGE_DEFAULT,
                  $typeRootNode = self::ANALYZER_TYPE_ROOT_NODE,
          Severity: Minor
          Found in src/module-elasticsuite-core/Index/Analysis/Config/Converter.php - About 45 mins to fix

            Function parseAnalyzers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                private function parseAnalyzers(
                    \DOMXPath $xpath,
                    array $availableCharFilters,
                    array $availableFilters,
                    $language = self::LANGUAGE_DEFAULT,
            Severity: Minor
            Found in src/module-elasticsuite-core/Index/Analysis/Config/Converter.php - About 25 mins 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

            There are no issues that match your filters.

            Category
            Status