Smile-SA/elasticsuite

View on GitHub

Showing 1,375 of 1,375 total issues

Function minMaxDecimation has 51 lines of code (exceeds 40 allowed). Consider refactoring.
Open

    function minMaxDecimation(data, start, count, availableWidth) {
        let avgX = 0;
        let countX = 0;
        let i, point, x, y, prevX, minIndex, maxIndex, startIndex, minY, maxY;
        const decimated = [];
Severity: Major
Found in src/module-elasticsuite-core/view/adminhtml/web/js/lib/chart.js - About 1 hr to fix

    Function bindAttributeInputType has 51 lines of code (exceeds 40 allowed). Consider refactoring.
    Open

                    bindAttributeInputType: function () {
                        this.checkOptionsPanelVisibility();
                        this.switchDefaultValueField();
    
                        var filterableFrontendInputs = $.merge(this.selectFields, ['text', 'boolean']);

      Function getTooltipSize has 51 lines of code (exceeds 40 allowed). Consider refactoring.
      Open

          function getTooltipSize(tooltip, options) {
              const ctx = tooltip._chart.ctx;
              const {body, footer, title} = tooltip;
              const {boxWidth, boxHeight} = options;
              const bodyFont = toFont(options.bodyFont);
      Severity: Major
      Found in src/module-elasticsuite-core/view/adminhtml/web/js/lib/chart.js - About 1 hr to fix

        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 build has 51 lines of code (exceeds 40 allowed). Consider refactoring.
          Open

              public function build(AggregationInterface $aggregation, ?int $storeId): array
              {
                  $bucket = $aggregation->getBucket(self::CATEGORY_BUCKET);
          
                  if ($this->isBucketEmpty($bucket)) {

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

                public function __construct(
                    \Magento\Framework\View\Element\Template\Context $context,
                    \Magento\Framework\Json\Helper\Data $jsonHelper,
                    \Smile\ElasticsuiteTracker\Helper\Data $trackerHelper,
                    \Magento\Framework\Registry $registry,
            src/module-elasticsuite-analytics/Block/Adminhtml/Report/DateRangeSwitcher.php on lines 55..66

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 79.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                public function __construct(
                    \Magento\Backend\Block\Template\Context $context,
                    \Smile\ElasticsuiteAnalytics\Model\Report\Context $reportContext,
                    \Smile\ElasticsuiteTracker\Model\IndexManager $indexManager,
                    \Magento\Framework\Serialize\Serializer\Json $jsonSerializer,
            src/module-elasticsuite-tracker/Block/Variables/AbstractBlock.php on lines 55..67

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 79.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

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

                public function getInputType()
                {
                    $inputType        = 'string';
                    $selectAttributes = ['attribute_set_id'];
            
            

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

                public function aroundExecute(
                    \Magento\CatalogSearch\Controller\Result\Index $subject,
                    \Closure $proceed
                ) {
                    $result = $proceed();

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

                public function modifyAttributes($storeId, $requestName, $attributes, $query, $filters, $queryFilters)
                {
                    $relevantAttributes = [];
                    $coverageRates      = $this->getCoverageRates($storeId, $requestName, $query, $filters, $queryFilters);
            
            

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

                public function modifyData(array $data)
                {
                    $optimizer = $this->locator->getOptimizer();
            
                    if ($optimizer && $optimizer->getId() && isset($data[$optimizer->getId()])) {

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

                private function getMetrics($rawValue)
                {
                    $metrics = [];
            
                    foreach ($rawValue as $metricName => $value) {

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

                protected function getGroupsForSave()
                {
                    $groups = $this->getRequest()->getPost('groups');
                    $files = $this->getRequest()->getFiles('groups');
            
            

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

                public function execute()
                {
                    /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
                    $resultRedirect = $this->resultRedirectFactory->create();
            
            

            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 12 (exceeds 5 allowed). Consider refactoring.
            Open

                public function indexEvents($events)
                {
                    $bulk    = $this->indexOperation->createBulk();
                    $indices = [];
            
            
            Severity: Minor
            Found in src/module-elasticsuite-tracker/Model/EventIndex.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 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

            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 11 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    OptimizerInterface $optimizer,
                    Preview\ItemFactory $previewItemFactory,
                    ApplierListFactory $applierListFactory,
                    Functions\ProviderFactory $providerFactory,
                    ContainerConfigurationInterface $containerConfig,

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

                      \Magento\Catalog\Model\Layer\Filter\ItemFactory $filterItemFactory,
                      \Magento\Store\Model\StoreManagerInterface $storeManager,
                      \Magento\Catalog\Model\Layer $layer,
                      \Magento\Catalog\Model\Layer\Filter\Item\DataBuilder $itemDataBuilder,
                      \Magento\Framework\Escaper $escaper,
              Severity: Major
              Found in src/module-elasticsuite-catalog/Model/Layer/Filter/Category.php - About 1 hr to fix

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

                        $name,
                        $field,
                        array $metrics = [],
                        array $childBuckets = [],
                        array $pipelines = [],

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

                          $name,
                          $field,
                          array $metrics = [],
                          array $childBuckets = [],
                          array $pipelines = [],
                    Severity
                    Category
                    Status
                    Source
                    Language