Smile-SA/elasticsuite

View on GitHub
src/module-elasticsuite-catalog-optimizer/Model/Optimizer.php

Summary

Maintainability
B
6 hrs
Test Coverage

Optimizer has 26 functions (exceeds 10 allowed). Consider refactoring.
Open

class Optimizer extends \Magento\Framework\Model\AbstractModel implements OptimizerInterface, IdentityInterface
{
    /**
     * @var string
     */
Severity: Minor
Found in src/module-elasticsuite-catalog-optimizer/Model/Optimizer.php - About 4 hrs to fix

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

            \Magento\Framework\Model\Context $context,
            \Magento\Framework\Registry $registry,
            \Smile\ElasticsuiteCatalogRule\Model\RuleFactory  $ruleFactory,
            \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter,
            \Magento\Framework\Serialize\SerializerInterface $serializer,
    Severity: Major
    Found in src/module-elasticsuite-catalog-optimizer/Model/Optimizer.php - About 1 hr to fix

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

          public function validateData(\Magento\Framework\DataObject $dataObject)
          {
              $result = [];
              $fromDate = $toDate = null;
      
      
      Severity: Minor
      Found in src/module-elasticsuite-catalog-optimizer/Model/Optimizer.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

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

          private function parseDateFields()
          {
              if ('' === $this->getFromDate()) {
                  $this->unsFromDate();
              }
      Severity: Minor
      Found in src/module-elasticsuite-catalog-optimizer/Model/Optimizer.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

      Doc-block of $resourceCollection in __construct is phpdoc param type \Magento\Framework\Data\Collection\AbstractDb which is not a permitted replacement of the nullable param type ?\Magento\Framework\Data\Collection\AbstractDb declared in the signature ('?T' should be documented as 'T|null' or '?T')
      Open

           * @param \Magento\Framework\Data\Collection\AbstractDb           $resourceCollection          Resource collection.

      Doc-block of $resource in __construct is phpdoc param type \Magento\Framework\Model\ResourceModel\AbstractResource which is not a permitted replacement of the nullable param type ?\Magento\Framework\Model\ResourceModel\AbstractResource declared in the signature ('?T' should be documented as 'T|null' or '?T')
      Open

           * @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource                    Resource.

      There are no issues that match your filters.

      Category
      Status