Smile-SA/elasticsuite

View on GitHub

Showing 1,375 of 1,375 total issues

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

<?php
/**
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Smile ElasticSuite to newer
src/module-elasticsuite-indices/Controller/Adminhtml/Analysis/Index.php on lines 1..46

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 72.

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 getNumberOfReplicasPerIndex(string $indexIdentifier): int
    {
        // Retrieve specific indices settings from the database.
        $customSettings = $this->getCustomIndicesSettings();

Severity: Major
Found in src/module-elasticsuite-core/Helper/IndexSettings.php and 1 other location - About 1 hr to fix
src/module-elasticsuite-core/Helper/IndexSettings.php on lines 257..272

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 72.

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

        if (count($subQueries) === 1) {
            $query = current($subQueries);
        } elseif (count($subQueries) > 1) {
            $query = $this->queryFactory->create(QueryInterface::TYPE_BOOL, ['should' => $subQueries]);
        }
src/module-elasticsuite-core/Search/Request/Query/Filter/QueryBuilder.php on lines 255..260

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 72.

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

        createChart: function (optionValue = null) {
            if (!this.chartRangesInit) {
                this.initRanges();
            }
            optionValue = typeof optionValue === 'object' ? null : optionValue;

    Function updateElements has 41 lines of code (exceeds 40 allowed). Consider refactoring.
    Open

            updateElements(arcs, start, count, mode) {
                const me = this;
                const reset = mode === 'reset';
                const chart = me.chart;
                const dataset = me.getDataset();
    Severity: Minor
    Found in src/module-elasticsuite-core/view/adminhtml/web/js/lib/chart.js - About 1 hr to fix

      Function pathArc has 41 lines of code (exceeds 40 allowed). Consider refactoring.
      Open

          function pathArc(ctx, element, offset, end) {
              const {x, y, startAngle: start, pixelMargin, innerRadius: innerR} = element;
              const outerRadius = Math.max(element.outerRadius + offset - pixelMargin, 0);
              const innerRadius = innerR > 0 ? innerR + offset + pixelMargin : 0;
              const alpha = end - start;
      Severity: Minor
      Found in src/module-elasticsuite-core/view/adminhtml/web/js/lib/chart.js - About 1 hr to fix

        Function getCaretPosition has 41 lines of code (exceeds 40 allowed). Consider refactoring.
        Open

                getCaretPosition(tooltipPoint, size, options) {
                    const {xAlign, yAlign} = this;
                    const {cornerRadius, caretSize} = options;
                    const {x: ptX, y: ptY} = tooltipPoint;
                    const {width, height} = size;
        Severity: Minor
        Found in src/module-elasticsuite-core/view/adminhtml/web/js/lib/chart.js - About 1 hr to fix

          Function fit has 41 lines of code (exceeds 40 allowed). Consider refactoring.
          Open

                  fit() {
                      const me = this;
                      const minSize = {
                          width: 0,
                          height: 0
          Severity: Minor
          Found in src/module-elasticsuite-core/view/adminhtml/web/js/lib/chart.js - About 1 hr to fix

            Method getChartData has 41 lines of code (exceeds 40 allowed). Consider refactoring.
            Open

                public function getChartData()
                {
                    $data = [
                        'cols' => [
                            ['type' => 'string', 'label' => __('Session type')],

              Method getQueries has 41 lines of code (exceeds 40 allowed). Consider refactoring.
              Open

                  private function getQueries()
                  {
                      $queries = [
                          'all'      => $this->queryFactory->create(
                              QueryInterface::TYPE_BOOL,

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

                            $this->getSelect()->join(
                                ['store_table' => $this->getTable(ThesaurusInterface::STORE_TABLE_NAME)],
                                'main_table.' . ThesaurusInterface::THESAURUS_ID . ' = store_table.' . ThesaurusInterface::THESAURUS_ID,
                                []
                            )->group(
                src/module-elasticsuite-thesaurus/Model/ResourceModel/Thesaurus/Collection.php on lines 142..148

                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 51.

                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

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

                        $this->getSelect()
                            ->join(
                                ['store_table' => $this->getTable(ThesaurusInterface::STORE_TABLE_NAME)],
                                'main_table.' . ThesaurusInterface::THESAURUS_ID . ' = store_table.' . ThesaurusInterface::THESAURUS_ID,
                                []
                src/module-elasticsuite-thesaurus/Model/ResourceModel/Thesaurus/Collection.php on lines 162..168

                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 51.

                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 getCurrentContainerLabel()
                    {
                        $containerLabel = '';
                        if ($this->getContainerCode() !== null) {
                            $container = $this->containersSource->get($this->getContainerCode());
                src/module-elasticsuite-core/Block/Adminhtml/Search/Request/RelevanceConfig/Scope/Switcher.php on lines 304..316

                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 71.

                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 getCurrentContainerName()
                    {
                        $containerName = '';
                        if ($this->getContainerCode() !== null) {
                            $container = $this->containersSource->get($this->getContainerCode());
                src/module-elasticsuite-core/Block/Adminhtml/Search/Request/RelevanceConfig/Scope/Switcher.php on lines 335..347

                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 71.

                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

                Method __construct has 8 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\Filter\StripTags $tagFilter,
                Severity: Major
                Found in src/module-elasticsuite-catalog/Model/Layer/Filter/Attribute.php - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                          if (($this->getAttribute()->getSourceModel() == 'Magento\Eav\Model\Entity\Attribute\Source\Boolean')
                              || ($this->getAttribute()->getBackendType() == 'int')
                              || ($this->getAttribute()->getFrontendClass() == 'validate-digits')
                              || ($this->getAttribute()->getBackendType() == 'decimal' || $this->getAttribute()->getFrontendClass() == 'validate-number')
                              || (in_array($this->getAttribute()->getFrontendInput(), ['select', 'multiselect'])

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

                            AttributeCollectionFactory $attributeCollectionFactory,
                            StoreManagerInterface $storeManager,
                            IndexOperationInterface $indexManager,
                            MappingHelper $mappingHelper,
                            RequestFieldMapper $requestFieldMapper,

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

                              \Magento\Customer\Model\Session $customerSession,
                              \Magento\Store\Model\StoreManagerInterface $storeManager,
                              \Smile\ElasticsuiteCore\Helper\Mapping $mappingHelper,
                              \Smile\ElasticsuiteCore\Api\Search\ContextInterface $searchContext,
                              \Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository,

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

                                $name,
                                $primaryFieldName,
                                $requestFieldName,
                                $collectionFactory,
                                array $addFieldStrategies = [],

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

                                  EntityFactory $entityFactory,
                                  LoggerInterface $logger,
                                  FetchStrategyInterface $fetchStrategy,
                                  ManagerInterface $eventManager,
                                  Data $resource,
                            Severity
                            Category
                            Status
                            Source
                            Language