EmicoEcommerce/Magento2Tweakwise

View on GitHub

Showing 169 of 169 total issues

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

    public function execute(Observer $observer)
    {
        if (!$this->config->isSearchEnabled()) {
            return;
        }
Severity: Minor
Found in Model/Observer/CatalogSearchRedirect.php - About 1 hr to fix

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

            UrlInterface $url,
            Registry $registry,
            Config $config,
            StoreManagerInterface $storeManager,
            CategoryRepositoryInterface $categoryRepository,
    Severity: Major
    Found in Model/FilterFormInputProvider/CategoryInputProvider.php - About 1 hr to fix

      Function getOriginalUrl has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getOriginalUrl(MagentoHttpRequest $request): string
          {
              $originalUrl = $request->getQuery('__tw_original_url');
              if ($originalUrl) {
                  $urlArray = explode('/', $originalUrl);
      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

      Function initFilters has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function initFilters(Layer $layer)
          {
              $request = $this->context->getRequest();
              if (!$request->hasParameter('tn_cid')) {
                  $request->addCategoryFilter($layer->getCurrentCategory());
      Severity: Minor
      Found in Model/Catalog/Layer/FilterList/Tweakwise.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 getOriginalUrl has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getOriginalUrl(MagentoHttpRequest $request): string
          {
              $twOriginalUrl = $request->getParam('__tw_original_url');
              if ($twOriginalUrl) {
                  // This seems ugly, perhaps there is another way?
      Severity: Minor
      Found in Model/Catalog/Layer/Url/Strategy/PathSlugStrategy.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 __construct has 10 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              ProductContext $productContext,
              PostHelper $postDataHelper,
              Resolver $layerResolver,
              TemplateFinder $templateFinder,
              CategoryRepositoryInterface $categoryRepository,
      Severity: Major
      Found in Block/Catalog/Product/ProductList/Featured.php - About 1 hr to fix

        Function findCurrentCategory has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            private function findCurrentCategory($items)
            {
                $storeId = $this->filter->getStoreId();
                $currentCategory = $this->filter->getLayer()->getCurrentCategory();
                $tweakwiseCategoryId = $this->helper->getTweakwiseId($storeId, $currentCategory->getId());
        Severity: Minor
        Found in Block/LayeredNavigation/RenderLayered/DefaultRenderer.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 __construct has 10 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                Config $config,
                RequestFactory $requestFactory,
                Client $client,
                Url $url,
                FilterableAttributeListInterface $filterableAttributes,
        Severity: Major
        Found in Model/Catalog/Layer/NavigationContext.php - About 1 hr to fix

          Function forProduct has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function forProduct(Product $product, $type)
              {
                  $attribute = $this->getAttribute($type);
                  $templateId = (int) $product->getData($attribute);
          
          
          Severity: Minor
          Found in Model/Config/TemplateFinder.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 getCollection has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getCollection(Category $category)
              {
                  if (!$this->config->isLayeredEnabled()) {
                      if (
                          !$this->config->isSearchEnabled() ||
          Severity: Minor
          Found in Model/Catalog/Layer/ItemCollectionProvider.php - About 1 hr to fix

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

                public function getAttributeSelectUrl(MagentoHttpRequest $request, Item $item): string
                {
                    $settings = $item
                        ->getFilter()
                        ->getFacet()
            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

              <?php
              
              /**
               * Tweakwise (https://www.tweakwise.com/) - All Rights Reserved
               *
              Severity: Major
              Found in Model/Client/Response/Catalog/TemplateResponse.php and 1 other location - About 1 hr to fix
              Model/Client/Response/Catalog/SortTemplateResponse.php on lines 1..30

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

              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

              <?php
              
              namespace Tweakwise\Magento2Tweakwise\Model\Client\Response\Catalog;
              
              use Tweakwise\Magento2Tweakwise\Model\Client\Response;
              Severity: Major
              Found in Model/Client/Response/Catalog/SortTemplateResponse.php and 1 other location - About 1 hr to fix
              Model/Client/Response/Catalog/TemplateResponse.php on lines 1..40

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

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

                  protected function ensureCrosssellTemplateAttribute(EavSetup $eavSetup)
                  {
                      foreach ([Category::ENTITY, Product::ENTITY] as $entityType) {
                          $eavSetup->addAttribute(
                              $entityType,
              Severity: Minor
              Found in Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php - About 1 hr to fix

                Method ensureCrosssellTemplateAttribute has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function ensureCrosssellTemplateAttribute(EavSetup $eavSetup)
                    {
                        foreach ([Category::ENTITY, Product::ENTITY] as $entityType) {
                            $eavSetup->addAttribute(
                                $entityType,
                Severity: Minor
                Found in Setup/InstallData.php - About 1 hr to fix

                  Function _ajaxHandler has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          _ajaxHandler: function (event) {
                              event.preventDefault();
                  
                              if(event.target.name == 'tw_filtersearch') {
                                  return;
                  Severity: Minor
                  Found in view/frontend/web/js/navigation-form.js - About 1 hr to fix

                    Method ensureUpsellTemplateAttribute has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        protected function ensureUpsellTemplateAttribute(EavSetup $eavSetup)
                        {
                            foreach ([Category::ENTITY, Product::ENTITY] as $entityType) {
                                $eavSetup->addAttribute(
                                    $entityType,
                    Severity: Minor
                    Found in Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php - About 1 hr to fix

                      Method ensureUpsellTemplateAttribute has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function ensureUpsellTemplateAttribute(EavSetup $eavSetup)
                          {
                              foreach ([Category::ENTITY, Product::ENTITY] as $entityType) {
                                  $eavSetup->addAttribute(
                                      $entityType,
                      Severity: Minor
                      Found in Setup/InstallData.php - About 1 hr to fix

                        Method getSwatchMap has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function getSwatchMap(): array
                            {
                                if ($this->swatchMap !== null) {
                                    return $this->swatchMap;
                                }
                        Severity: Minor
                        Found in Model/Swatches/SwatchAttributeResolver.php - About 1 hr to fix

                          Method ensureShoppingcartCrosssellTemplateAttribute has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              protected function ensureShoppingcartCrosssellTemplateAttribute(EavSetup $eavSetup)
                              {
                                  foreach ([Category::ENTITY, Product::ENTITY] as $entityType) {
                                      $eavSetup->addAttribute(
                                          $entityType,
                          Severity: Minor
                          Found in Setup/Patch/Data/AddRecommendationCategoryFieldsPatch.php - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language