EmicoEcommerce/Magento2Tweakwise

View on GitHub

Showing 156 of 156 total issues

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

    private function getShoppingcartCrosssellItems(array $cartProductIds, array $result)
    {
        $items = [];

        if ($cartProductIds) {
Severity: Minor
Found in Block/Cart/Crosssell/Plugin.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 getShoppingcartCrosssellItems has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    private function getShoppingcartCrosssellItems(array $cartProductIds, array $result)
    {
        $items = [];

        if ($cartProductIds) {
Severity: Minor
Found in Block/Checkout/Cart/Crosssell/Plugin.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

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

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

          public function __construct(
              Config $config,
              UrlInterface $url,
              CurrentContext $currentNavigationContext,
              ProductMetadataInterface $productMetadata,
      Severity: Major
      Found in Model/NavigationConfig.php and 2 other locations - About 2 hrs to fix
      Model/Autocomplete/DataProvider/SuggestionDataProvider.php on lines 72..90
      Model/Autocomplete/DataProviderHelper.php on lines 74..92

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

      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

          public function __construct(
              Config $config,
              CookieManagerInterface $cookieManager,
              DataProviderHelper $dataProviderHelper,
              SuggestionGroupItemFactory $suggestionGroupItemFactory,
      Severity: Major
      Found in Model/Autocomplete/DataProvider/SuggestionDataProvider.php and 2 other locations - About 2 hrs to fix
      Model/Autocomplete/DataProviderHelper.php on lines 74..92
      Model/NavigationConfig.php on lines 76..94

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

      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

          public function __construct(
              Config $config,
              QueryFactory $queryFactory,
              StoreManagerInterface $storeManager,
              CategoryRepositoryInterface $categoryRepository,
      Severity: Major
      Found in Model/Autocomplete/DataProviderHelper.php and 2 other locations - About 2 hrs to fix
      Model/Autocomplete/DataProvider/SuggestionDataProvider.php on lines 72..90
      Model/NavigationConfig.php on lines 76..94

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

      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 Filter.php has 272 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/Filter.php - About 2 hrs to fix

        File navigation-form.js has 269 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /**
         * Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
         *
         * @copyright Copyright (c) 2017-2022 Tweakwise.com B.V. (https://www.tweakwise.com)
         * @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
        Severity: Minor
        Found in view/frontend/web/js/navigation-form.js - 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

            Method getSwatchData has 55 lines of code (exceeds 25 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: Major
            Found in Block/LayeredNavigation/RenderLayered/SwatchRenderer.php - About 2 hrs to fix

              Function apply has a Cognitive Complexity of 16 (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 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 execute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function execute()
                  {
                      $json = $this->resultFactory->create('json');
                      $facetRequest = $this->requestFactory->create();
              
              
              Severity: Minor
              Found in Controller/Ajax/FacetAttributes.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

              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

                Method apply has 44 lines of code (exceeds 25 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

                  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

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

                          _handleLessItemsLink: function () {
                              this._sortItems('original-sort');
                              this.element.find('.default-hidden').hide();
                              this.element.find('.more-items').show();
                  
                  
                  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 38..44

                  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

                  Method getItems has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function getItems()
                      {
                          $query = $this->dataProviderHelper->getQuery();
                          $category = $this->dataProviderHelper->getCategory();
                          $promises = [];
                  Severity: Minor
                  Found in Model/Autocomplete/DataProvider/SuggestionDataProvider.php - About 1 hr to fix

                    Similar blocks of code found in 2 locations. 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: Major
                    Found in Model/Config/Source/FeaturedLocation.php and 1 other location - About 1 hr to fix
                    Model/Config/Source/CrosssellTemplateType.php on lines 1..47

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

                    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