EmicoEcommerce/Magento2TweakwiseExport

View on GitHub
Model/Write/EavIterator.php

Summary

Maintainability
D
1 day
Test Coverage

File EavIterator.php has 314 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
 *
Severity: Minor
Found in Model/Write/EavIterator.php - About 3 hrs to fix

    Function loopUnionRows has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function loopUnionRows(MysqlStatement $stmt)
        {
            $entity = ['entity_id' => null];
            while ($row = $stmt->fetch()) {
                $attributeId = $row['attribute_id'];
    Severity: Minor
    Found in Model/Write/EavIterator.php - About 2 hrs 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

    EavIterator has 22 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class EavIterator implements IteratorAggregate
    {
        /**
         * @var int
         */
    Severity: Minor
    Found in Model/Write/EavIterator.php - About 2 hrs to fix

      Method loopUnionRows has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function loopUnionRows(MysqlStatement $stmt)
          {
              $entity = ['entity_id' => null];
              while ($row = $stmt->fetch()) {
                  $attributeId = $row['attribute_id'];
      Severity: Minor
      Found in Model/Write/EavIterator.php - About 1 hr to fix

        Method getIterator has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getIterator(): \Traversable
            {
                while ($entityIds = $this->getEntityBatch()) {
                    try {
                        Profiler::start('eav-iterator::' . $this->entityCode);
        Severity: Minor
        Found in Model/Write/EavIterator.php - About 1 hr to fix

          Method getAttributeSelectEnterprise has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function getAttributeSelectEnterprise(string $table, array $attributes): Select
              {
                  $connection = $this->getConnection();
                  $select = $connection->select()
                      ->from(['attribute_table' => $table], [])
          Severity: Minor
          Found in Model/Write/EavIterator.php - About 1 hr to fix

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

                    Helper $helper,
                    EavConfig $eavConfig,
                    DbContext $dbContext,
                    Manager $eventManager,
                    string $entityCode,
            Severity: Major
            Found in Model/Write/EavIterator.php - About 50 mins to fix

              Function getAttributeSelects has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function getAttributeSelects(): array
                  {
                      $selects = [];
                      $attributeGroups = $this->getAttributeGroups();
              
              
              Severity: Minor
              Found in Model/Write/EavIterator.php - About 35 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 getIterator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getIterator(): \Traversable
                  {
                      while ($entityIds = $this->getEntityBatch()) {
                          try {
                              Profiler::start('eav-iterator::' . $this->entityCode);
              Severity: Minor
              Found in Model/Write/EavIterator.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