EmicoEcommerce/Magento2TweakwiseExport

View on GitHub

Showing 83 of 111 total issues

ExportEntity has 32 functions (exceeds 20 allowed). Consider refactoring.
Open

class ExportEntity
{
    /**
     * @var Store
     */
Severity: Minor
Found in Model/Write/Products/ExportEntity.php - About 4 hrs to fix

    Method getStockItemMap has 97 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function getStockItemMap(Collection|StockCollection $collection): array
        {
            if ($collection->count() === 0) {
                return [];
            }

      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

        ExportEntity has 29 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ExportEntity
        {
            /**
             * @var Store
             */
        Severity: Minor
        Found in Model/Write/Price/ExportEntity.php - About 3 hrs to fix

          ExportEntity has 29 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class ExportEntity
          {
              /**
               * @var Store
               */
          Severity: Minor
          Found in Model/Write/Stock/ExportEntity.php - About 3 hrs to fix

            Method execute has 79 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function execute(InputInterface $input, OutputInterface $output)
                {
                    return $this->state->emulateAreaCode(
                        Area::AREA_CRONTAB,
                        function () use ($input, $output) {
            Severity: Major
            Found in Console/Command/ExportCommand.php - About 3 hrs to fix

              Function exportStore has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function exportStore(Writer $writer, XMLWriter $xml, Store $store, array $entityIds = []): void
                  {
                      // Set root category as exported
                      $exportedCategories = [1 => true];
                      $storeId = $store->getId();
              Severity: Minor
              Found in Model/Write/Categories.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

              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 generateToFile has 49 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function generateToFile($feedFile, $validate, $store = null, $type = null): void
                    {
                        $this->executeLocked(
                            function () use ($feedFile, $validate, $store, $type) {
                                $tmpFeedFile = $this->config->getFeedTmpFile($feedFile, $store);
                Severity: Minor
                Found in Model/Export.php - About 1 hr to fix

                  Function decorate has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function decorate(Collection|StockCollection $collection): void
                      {
                          foreach ($collection as $exportEntity) {
                              if (!$exportEntity instanceof CompositeExportEntityInterface) {
                                  continue;
                  Severity: Minor
                  Found in Model/Write/Products/CollectionDecorator/ChildrenAttributes.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 getStockItem has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getStockItem(): ?StockItem
                      {
                          if ($this->isStockCombined) {
                              return $this->stockItem;
                          }
                  Severity: Minor
                  Found in Model/Write/Products/ExportEntityBundle.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 createChildEntities has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function createChildEntities(Collection|StockCollection|PriceCollection $collection): void
                      {
                          foreach ($this->getCompositeEntities($collection) as $typeId => $group) {
                              // Create fake product type to trick type factory to use getTypeId
                              /** @var Product $fakeProduct */
                  Severity: Minor
                  Found in Model/Write/Products/CollectionDecorator/Children.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 getStockItem has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getStockItem(): ?StockItem
                      {
                          if ($this->isStockCombined) {
                              return $this->stockItem;
                          }
                  Severity: Minor
                  Found in Model/Write/Products/ExportEntityBundle.php - About 1 hr to fix

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

                            ProductRepositoryInterface $productRepository,
                            ProductInterfaceFactory $productFactory,
                            StockRegistryInterface $stockRegistry,
                            CategoryLinkManagementInterface $categoryLinkManagement,
                            EntityHydrator $hydrator,
                    Severity: Major
                    Found in TestHelper/Data/ProductProvider.php - About 1 hr to fix

                      Method addBundleChildren has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function addBundleChildren(Collection|StockCollection|PriceCollection $collection, array $parentIds): void
                          {
                              $connection = $this->dbResource->getConnection();
                              $select = $connection->select();
                      
                      
                      Severity: Minor
                      Found in Model/Write/Products/CollectionDecorator/Children.php - About 1 hr to fix

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

                            protected function shouldExportByChildStatus(): bool
                            {
                                $optionGroupStatus = [];
                                foreach ($this->getAllChildren() as $child) {
                                    $childOptions = $child->getChildOptions();
                        Severity: Minor
                        Found in Model/Write/Products/ExportEntityBundle.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 normalizeAttributeValue has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function normalizeAttributeValue(int $storeId, string $attributeCode, $value): array
                            {
                                $values = $this->ensureArray($value);
                                $values = array_map(
                                    function ($value) {
                        Severity: Minor
                        Found in Model/Write/Products.php - About 1 hr to fix

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

                              public function exportStore(Writer $writer, XMLWriter $xml, Store $store, array $entityIds = []): void
                              {
                                  // Set root category as exported
                                  $exportedCategories = [1 => true];
                                  $storeId = $store->getId();
                          Severity: Minor
                          Found in Model/Write/Categories.php - About 1 hr 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
                              Severity
                              Category
                              Status
                              Source
                              Language