EmicoEcommerce/Magento2Tweakwise

View on GitHub

Showing 156 of 156 total issues

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

define([
    'jquery',
    'jquery/ui',
    'jQueryTouchPunch',
    'domReady!'
Severity: Major
Found in view/frontend/web/js/navigation-slider-compat.js and 2 other locations - About 1 wk to fix
view/frontend/web/js/navigation-slider-widget.js on lines 8..196
view/frontend/web/js/navigation-slider.js on lines 8..196

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

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

define([
    'jquery',
    'jquery/ui-modules/widgets/slider',
    'jQueryTouchPunch',
    'domReady!'
Severity: Major
Found in view/frontend/web/js/navigation-slider-widget.js and 2 other locations - About 1 wk to fix
view/frontend/web/js/navigation-slider-compat.js on lines 8..196
view/frontend/web/js/navigation-slider.js on lines 8..196

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

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

define([
    'jquery',
    'jquery-ui-modules/slider',
    'jQueryTouchPunch',
    'domReady!'
Severity: Major
Found in view/frontend/web/js/navigation-slider.js and 2 other locations - About 1 wk to fix
view/frontend/web/js/navigation-slider-compat.js on lines 8..196
view/frontend/web/js/navigation-slider-widget.js on lines 8..196

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

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(
        CollectionEntityFactory $entityFactory,
        LoggerInterface $logger,
        FetchStrategyInterface $fetchStrategy,
        ManagerInterface $eventManager,
Severity: Major
Found in Model/Catalog/Product/Collection.php and 1 other location - About 7 hrs to fix
Model/Catalog/Product/Recommendation/Collection.php on lines 44..91

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

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(
        CollectionEntityFactory $entityFactory,
        LoggerInterface $logger,
        FetchStrategyInterface $fetchStrategy,
        ManagerInterface $eventManager,
Severity: Major
Found in Model/Catalog/Product/Recommendation/Collection.php and 1 other location - About 7 hrs to fix
Model/Catalog/Product/Collection.php on lines 45..93

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

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

    private function getShoppingcartCrosssellTweakwiseItems (ProductInterface $product, array $result, array $cartItems) {
        $items = [];

        //show featured products
        if ($this->getType() === Config::RECCOMENDATION_TYPE_SHOPPINGCART_FEATURED) {
Severity: Major
Found in Block/Cart/Crosssell/Plugin.php and 1 other location - About 6 hrs to fix
Block/Checkout/Cart/Crosssell/Plugin.php on lines 180..215

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

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

    private function getShoppingcartCrosssellTweakwiseItems (ProductInterface $product, array $result, array $cartItems) {
        $items = [];

        //show featured products
        if ($this->getType() === Config::RECCOMENDATION_TYPE_SHOPPINGCART_FEATURED) {
Severity: Major
Found in Block/Checkout/Cart/Crosssell/Plugin.php and 1 other location - About 6 hrs to fix
Block/Cart/Crosssell/Plugin.php on lines 200..235

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

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

Config has 45 functions (exceeds 20 allowed). Consider refactoring.
Open

class Config
{
    /**
     * Recommendation types
     */
Severity: Minor
Found in Model/Config.php - About 6 hrs to fix

    Function getSwatchData has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getSwatchData()
        {
            if (false === $this->eavAttribute instanceof Attribute) {
                throw new \RuntimeException('Magento_Swatches: RenderLayered: Attribute has not been set.');
            }
    Severity: Minor
    Found in Block/LayeredNavigation/RenderLayered/SwatchRenderer.php - About 5 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

    File QueryParameterStrategy.php has 365 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
     *
     * @copyright Copyright (c) 2017-2022 Tweakwise.com B.V. (https://www.tweakwise.com)
    Severity: Minor
    Found in Model/Catalog/Layer/Url/Strategy/QueryParameterStrategy.php - About 4 hrs to fix

      Filter has 36 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Filter extends AbstractFilter implements FilterInterface
      {
          /**
           * @var string
           */
      Severity: Minor
      Found in Model/Catalog/Layer/Filter.php - About 4 hrs to fix

        File PathSlugStrategy.php has 348 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
         *
         * @copyright Copyright (c) 2017-2022 Tweakwise.com B.V. (https://www.tweakwise.com)
        Severity: Minor
        Found in Model/Catalog/Layer/Url/Strategy/PathSlugStrategy.php - About 4 hrs to fix

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

              protected function ensureShoppingcartCrosssellTemplateAttribute(EavSetup $eavSetup)
              {
                  foreach ([Category::ENTITY, Product::ENTITY] as $entityType) {
                      $eavSetup->addAttribute($entityType, Config::ATTRIBUTE_SHOPPINGCART_CROSSSELL_TEMPLATE, [
                          'type' => 'int',
          Severity: Major
          Found in Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php and 4 other locations - About 3 hrs to fix
          Setup/InstallData.php on lines 71..95
          Setup/InstallData.php on lines 97..121
          Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php on lines 110..134
          Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php on lines 136..160

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

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

              protected function ensureCrosssellTemplateAttribute(EavSetup $eavSetup)
              {
                  foreach ([Category::ENTITY, Product::ENTITY] as $entityType) {
                      $eavSetup->addAttribute($entityType, Config::ATTRIBUTE_CROSSSELL_TEMPLATE, [
                          'type' => 'int',
          Severity: Major
          Found in Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php and 4 other locations - About 3 hrs to fix
          Setup/InstallData.php on lines 71..95
          Setup/InstallData.php on lines 97..121
          Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php on lines 84..108
          Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php on lines 136..160

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

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

              protected function ensureUpsellTemplateAttribute(EavSetup $eavSetup)
              {
                  foreach ([Category::ENTITY, Product::ENTITY] as $entityType) {
                      $eavSetup->addAttribute($entityType, Config::ATTRIBUTE_UPSELL_TEMPLATE, [
                          'type' => 'int',
          Severity: Major
          Found in Setup/InstallData.php and 4 other locations - About 3 hrs to fix
          Setup/InstallData.php on lines 71..95
          Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php on lines 84..108
          Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php on lines 110..134
          Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php on lines 136..160

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

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

              protected function ensureCrosssellTemplateAttribute(EavSetup $eavSetup)
              {
                  foreach ([Category::ENTITY, Product::ENTITY] as $entityType) {
                      $eavSetup->addAttribute($entityType, Config::ATTRIBUTE_CROSSSELL_TEMPLATE, [
                          'type' => 'int',
          Severity: Major
          Found in Setup/InstallData.php and 4 other locations - About 3 hrs to fix
          Setup/InstallData.php on lines 97..121
          Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php on lines 84..108
          Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php on lines 110..134
          Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php on lines 136..160

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

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

              protected function ensureUpsellTemplateAttribute(EavSetup $eavSetup)
              {
                  foreach ([Category::ENTITY, Product::ENTITY] as $entityType) {
                      $eavSetup->addAttribute($entityType, Config::ATTRIBUTE_UPSELL_TEMPLATE, [
                          'type' => 'int',
          Severity: Major
          Found in Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php and 4 other locations - About 3 hrs to fix
          Setup/InstallData.php on lines 71..95
          Setup/InstallData.php on lines 97..121
          Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php on lines 84..108
          Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php on lines 110..134

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

          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

          File Config.php has 300 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
           *
           * @copyright Copyright (c) 2017-2022 Tweakwise.com B.V. (https://www.tweakwise.com)
          Severity: Minor
          Found in Model/Config.php - About 3 hrs to fix

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

                private function getShoppingcartCrosssellItems(array $cartProductIds, array $result)
                {
                    $items = [];
            
                    if ($cartProductIds) {
            Severity: Major
            Found in Block/Cart/Crosssell/Plugin.php and 1 other location - About 3 hrs to fix
            Block/Checkout/Cart/Crosssell/Plugin.php on lines 143..172

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

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

                private function getShoppingcartCrosssellItems(array $cartProductIds, array $result)
                {
                    $items = [];
            
                    if ($cartProductIds) {
            Severity: Major
            Found in Block/Checkout/Cart/Crosssell/Plugin.php and 1 other location - About 3 hrs to fix
            Block/Cart/Crosssell/Plugin.php on lines 163..192

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

            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

            Severity
            Category
            Status
            Source
            Language