EmicoEcommerce/Magento2Tweakwise

View on GitHub

Showing 93 of 93 total issues

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

define([
    'jquery',
    'jquery/ui',
    'jQueryTouchPunch',
    'domReady!'
Severity: Major
Found in view/frontend/web/js/navigation-slider-compat.js and 1 other location - About 1 wk to fix
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 2 locations. Consider refactoring.
Open

define([
    'jquery',
    'jquery-ui-modules/slider',
    'jQueryTouchPunch',
    'domReady!'
Severity: Major
Found in view/frontend/web/js/navigation-slider.js and 1 other location - About 1 wk to fix
view/frontend/web/js/navigation-slider-compat.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

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

class Config
{
    /**
     * Recommendation types
     */
Severity: Minor
Found in Model/Config.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 327 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

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

        Similar blocks of code found in 2 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/UpgradeData.php and 1 other location - About 3 hrs to fix
        Setup/UpgradeData.php on lines 69..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 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 2 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/UpgradeData.php and 1 other location - About 3 hrs to fix
        Setup/UpgradeData.php on lines 95..119

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

        !function(a){function f(a,b){if(!(a.originalEvent.touches.length>1)){a.preventDefault();var c=a.originalEvent.changedTouches[0],d=document.createEvent("MouseEvents");d.initMouseEvent(b,!0,!0,window,1,c.screenX,c.screenY,c.clientX,c.clientY,!1,!1,!1,!1,0,null),a.target.dispatchEvent(d)}}if(a.support.touch="ontouchend"in document,a.support.touch){var e,b=a.ui.mouse.prototype,c=b._mouseInit,d=b._mouseDestroy;b._touchStart=function(a){var b=this;!e&&b._mouseCapture(a.originalEvent.changedTouches[0])&&(e=!0,b._touchMoved=!1,f(a,"mouseover"),f(a,"mousemove"),f(a,"mousedown"))},b._touchMove=function(a){e&&(this._touchMoved=!0,f(a,"mousemove"))},b._touchEnd=function(a){e&&(f(a,"mouseup"),f(a,"mouseout"),this._touchMoved||f(a,"click"),e=!1)},b._mouseInit=function(){var b=this;b.element.bind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),c.call(b)},b._mouseDestroy=function(){var b=this;b.element.unbind({touchstart:a.proxy(b,"_touchStart"),touchmove:a.proxy(b,"_touchMove"),touchend:a.proxy(b,"_touchEnd")}),d.call(b)}}}(jQuery);
        Severity: Major
        Found in view/frontend/web/js/lib/jquery.ui.touch-punch.min.js and 1 other location - About 2 hrs to fix
        view/frontend/web/js/lib/jquery.ui.touch-punch.min.js on lines 11..11

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

        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 21 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                CollectionEntityFactory $entityFactory,
                LoggerInterface $logger,
                FetchStrategyInterface $fetchStrategy,
                ManagerInterface $eventManager,
                EavConfig $eavConfig,
        Severity: Major
        Found in Model/Catalog/Product/Collection.php - About 2 hrs to fix

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

                  CollectionEntityFactory $entityFactory,
                  LoggerInterface $logger,
                  FetchStrategyInterface $fetchStrategy,
                  ManagerInterface $eventManager,
                  EavConfig $eavConfig,
          Severity: Major
          Found in Model/Catalog/Product/Recommendation/Collection.php - About 2 hrs to fix

            File Filter.php has 272 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Tweakwise & Emico (https://www.tweakwise.com/ & https://www.emico.nl/) - All Rights Reserved
             *
             * @copyright Copyright (c) 2017-2017 Tweakwise.com B.V. (https://www.tweakwise.com)
            Severity: Minor
            Found in Model/Catalog/Layer/Filter.php - About 2 hrs to fix

              Function _updateBlocks has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      _updateBlocks: function (htmlResponse) {
                          var filterSelector = this.options.filterSelector;
                          var productListSelector = this.options.productListSelector;
                          var toolbarSelector = this.options.toolbarSelector;
              
              
              Severity: Major
              Found in view/frontend/web/js/navigation-form.js - About 2 hrs to fix

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

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

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

                          ConfigInterface $routeConfig,
                          RequestInterface $request,
                          SecurityInfoInterface $urlSecurityInfo,
                          ScopeResolverInterface $scopeResolver,
                          Generic $session,
                  Severity: Major
                  Found in Model/Catalog/Layer/Url/UrlModel.php - About 2 hrs to fix

                    Function apply has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function apply(MagentoHttpRequest $request, ProductNavigationRequest $navigationRequest): FilterApplierInterface
                        {
                            $attributeFilters = $this->getAttributeFilters($request);
                            foreach ($attributeFilters as $attribute => $values) {
                                if (!is_array($values)) {
                    Severity: Minor
                    Found in Model/Catalog/Layer/Url/Strategy/QueryParameterStrategy.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

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

                        public function __construct(
                            UrlInterface $url,
                            Registry $registry,
                            Config $config,
                            StoreManagerInterface $storeManager,
                    Severity: Major
                    Found in Model/FilterFormInputProvider/CategoryInputProvider.php and 1 other location - About 1 hr to fix
                    Model/NavigationConfig.php on lines 74..90

                    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(
                            Config $config,
                            UrlInterface $url,
                            CurrentContext $currentNavigationContext,
                            ProductMetadataInterface $productMetadata,
                    Severity: Major
                    Found in Model/NavigationConfig.php and 1 other location - About 1 hr to fix
                    Model/FilterFormInputProvider/CategoryInputProvider.php on lines 69..85

                    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

                            _handleMoreItemsLink: function () {
                                this._sortItems('alternate-sort');
                                this.element.find('.default-hidden').show();
                                this.element.find('.more-items').hide();
                    
                    
                    Severity: Major
                    Found in view/frontend/web/js/navigation-sort.js and 1 other location - About 1 hr to fix
                    view/frontend/web/js/navigation-sort.js on lines 52..58

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

                    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