Smile-SA/elasticsuite

View on GitHub

Showing 1,375 of 1,375 total issues

Function aroundGetData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function aroundGetData(CategoryDataProvider $dataProvider, \Closure $proceed)
    {
        $data = $proceed();

        $currentCategory = $dataProvider->getCurrentCategory();

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

    private function updateAttributeData($attribute, $rowData)
    {
        $dataChanged = false;

        foreach ($rowData as $key => $value) {
Severity: Minor
Found in src/module-elasticsuite-catalog/Model/Import/ProductAttribute.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

Function prepareFieldCondition has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function prepareFieldCondition(FieldInterface $field, $condition, $currentPath)
    {
        $queryType = QueryInterface::TYPE_TERMS;
        $condition = $this->prepareCondition($condition);

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

    public function buildSordOrders(ContainerConfigurationInterface $containerConfig, array $orders)
    {
        $sortOrders = [];
        $mapping    = $containerConfig->getMapping();

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

    public function create(ContainerConfigurationInterface $containerConfig, $queryText, $spellingType, $boost = 1, $depth = 0)
    {
        $query = null;

        $fuzzySpellingTypes = [SpellcheckerInterface::SPELLING_TYPE_FUZZY, SpellcheckerInterface::SPELLING_TYPE_MOST_FUZZY];

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

    protected function processNestedGroups($group)
    {
        $data = [];

        if (isset($group['fields']) && is_array($group['fields'])) {

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

    private function saveTermsRelation(\Magento\Framework\Model\AbstractModel $object)
    {
        $termRelations = $object->getTermsRelations() ?? [];
        $termRelations = array_filter($termRelations);

Severity: Minor
Found in src/module-elasticsuite-thesaurus/Model/ResourceModel/Thesaurus.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 getFilterArray has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    private function getFilterArray(array $request, \Magento\Catalog\Model\Product $product)
    {
        $filterArray = [];
        $attributes = $this->eavConfig->getEntityAttributes(\Magento\Catalog\Model\Product::ENTITY, $product);

Severity: Minor
Found in src/module-elasticsuite-swatches/Model/Plugin/ProductImage.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

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

    public function __construct(
        RequestFactory $requestFactory,
        DimensionFactory $dimensionFactory,
        QueryBuilder $queryBuilder,
        SortOrderBuilder $sortOrderBuilder,
Severity: Major
Found in src/module-elasticsuite-core/Search/Request/Builder.php and 1 other location - About 1 hr to fix
src/module-elasticsuite-core/Search/Request/Query/MultiMatch.php on lines 100..120

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

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(
        $queryText,
        array $fields,
        $minimumShouldMatch = self::DEFAULT_MINIMUM_SHOULD_MATCH,
        $tieBreaker = self::DEFAULT_TIE_BREAKER,
src/module-elasticsuite-core/Search/Request/Builder.php on lines 97..117

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

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

        _calculateBarValuePixels(index) {
            const me = this;
            const {vScale, _stacked} = me._cachedMeta;
            const {base: baseValue, minBarLength} = me.options;
            const parsed = me.getParsed(index);
Severity: Major
Found in src/module-elasticsuite-core/view/adminhtml/web/js/lib/chart.js - About 1 hr to fix

    Function constructor has 54 lines of code (exceeds 40 allowed). Consider refactoring.
    Open

            constructor(item, config) {
                const me = this;
                this.config = config = new Config(config);
                const initialCanvas = getCanvas(item);
                const existingChart = getChart(initialCanvas);
    Severity: Major
    Found in src/module-elasticsuite-core/view/adminhtml/web/js/lib/chart.js - About 1 hr to fix

      Function beforeElementsUpdate has 54 lines of code (exceeds 40 allowed). Consider refactoring.
      Open

              beforeElementsUpdate: (chart, args, options) => {
                  if (!options.enabled) {
                      cleanDecimatedData(chart);
                      return;
                  }
      Severity: Major
      Found in src/module-elasticsuite-core/view/adminhtml/web/js/lib/chart.js - About 1 hr to fix

        Method afterCreateCollection has 53 lines of code (exceeds 40 allowed). Consider refactoring.
        Open

            public function afterCreateCollection(ProductsList $subject, $collection)
            {
                $storeId    = $this->getCurrentStoreId($subject);
                $sortOption = $subject->getData('sort_order');
                $conditionOption = $subject->getData('condition_option');

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

                  $name,
                  $indexName,
                  QueryInterface $query,
                  QueryInterface $filter = null,
                  array $sortOrders = null,
          Severity: Major
          Found in src/module-elasticsuite-core/Search/Request.php - About 1 hr to fix

            Function getDataSets has 52 lines of code (exceeds 40 allowed). Consider refactoring.
            Open

                    getDataSets: function (optionValue) {
                        optionValue =  this.currentOptionValue;
                        var datasets = [];
                        var DataSetsConfig =  {
                            'ln1p': {

              Function success has 52 lines of code (exceeds 40 allowed). Consider refactoring.
              Open

                                  success: $.proxy(function (data) {
                                      var self = this;
                                      var lastElement = false;
                                      var content = this._getResultWrapper();
                                      var sectionDropdown = this._getSectionHeader();
              Severity: Major
              Found in src/module-elasticsuite-core/view/frontend/web/js/form-mini.js - About 1 hr to fix

                Method addFacetFields has 52 lines of code (exceeds 40 allowed). Consider refactoring.
                Open

                    private function addFacetFields(Fieldset $fieldset)
                    {
                        $fieldset->addField(
                            'facet_min_coverage_rate',
                            'text',

                  Method execute has 52 lines of code (exceeds 40 allowed). Consider refactoring.
                  Open

                      public function execute()
                      {
                          // Prepare product attributes grid collection.
                          $attributeCollectionFactory = $this->attributeCollectionFactory->create();
                          $attributeCollection = $attributeCollectionFactory->addVisibleFilter()
                    Severity
                    Category
                    Status
                    Source
                    Language