EmicoEcommerce/Magento2TweakwiseExport

View on GitHub

Showing 111 of 111 total issues

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

        if ($this->helper->isEnterprise()) {
            $select
                ->from(['product_table' => $this->dbResource->getTableName('catalog_product_entity')])
                ->reset('columns')
                ->columns(['parent_id' => 'product_table.entity_id'])
Severity: Major
Found in Model/Write/Products/CollectionDecorator/Children.php and 1 other location - About 2 hrs to fix
Model/Write/Products/CollectionDecorator/Children.php on lines 174..190

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

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 ($this->helper->isEnterprise()) {
            $select
                ->from(['product_table' => $this->dbResource->getTableName('catalog_product_entity')])
                ->reset('columns')
                ->columns(['parent_product_id' => 'product_table.entity_id'])
Severity: Major
Found in Model/Write/Products/CollectionDecorator/Children.php and 1 other location - About 2 hrs to fix
Model/Write/Products/CollectionDecorator/Children.php on lines 263..279

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

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 3 locations. Consider refactoring.
Open

    public function __construct(
        Helper $helper,
        EavConfig $eavConfig,
        DbContext $dbContext,
        Manager $eventManager,
Severity: Major
Found in Model/Write/Products/Iterator.php and 2 other locations - About 2 hrs to fix
Model/Write/Price/Iterator.php on lines 53..79
Model/Write/Stock/Iterator.php on lines 53..79

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

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 3 locations. Consider refactoring.
Open

    public function __construct(
        Helper $helper,
        EavConfig $eavConfig,
        DbContext $dbContext,
        Manager $eventManager,
Severity: Major
Found in Model/Write/Stock/Iterator.php and 2 other locations - About 2 hrs to fix
Model/Write/Price/Iterator.php on lines 53..79
Model/Write/Products/Iterator.php on lines 52..78

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

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 3 locations. Consider refactoring.
Open

    public function __construct(
        Helper $helper,
        EavConfig $eavConfig,
        DbContext $dbContext,
        Manager $eventManager,
Severity: Major
Found in Model/Write/Price/Iterator.php and 2 other locations - About 2 hrs to fix
Model/Write/Products/Iterator.php on lines 52..78
Model/Write/Stock/Iterator.php on lines 53..79

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

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

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

          public function __construct(
              Context $context,
              ExportModel $export,
              Logger $log,
              RequestValidator $requestValidator,
      Severity: Major
      Found in Controller/Feed/Export.php and 1 other location - About 1 hr to fix
      Model/Write/Products/CollectionDecorator/StockData/SourceItemMapProvider.php on lines 83..99

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

      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(
              DbResourceHelper $dbResource,
              StockSourceProviderFactory $stockSourceProviderFactory,
              TweakwiseStockItemFactory $tweakwiseStockItemFactory,
              StoreManagerInterface $storeManager,
      Controller/Feed/Export.php on lines 72..88

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

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

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

            public function getProduct(int $entityId, string $storeCode = null): ProductData
            {
                $this->parseProducts();
        
                $store = $this->getStore($storeCode);
        Severity: Major
        Found in TestHelper/FeedData.php and 1 other location - About 1 hr to fix
        TestHelper/FeedData.php on lines 94..106

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

        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 getCategory(int $entityId, string $storeCode = null): CategoryData
            {
                $this->parseCategories();
        
                $store = $this->getStore($storeCode);
        Severity: Major
        Found in TestHelper/FeedData.php and 1 other location - About 1 hr to fix
        TestHelper/FeedData.php on lines 113..125

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

        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 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
              Severity
              Category
              Status
              Source
              Language