EmicoEcommerce/Magento2Tweakwise

View on GitHub

Showing 169 of 169 total issues

Function buildFilterSlugPath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    protected function buildFilterSlugPath(array $filters): string
    {
        if (empty($filters)) {
            return '';
        }
Severity: Minor
Found in Model/Catalog/Layer/Url/Strategy/PathSlugStrategy.php - About 45 mins 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 getSwatchData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function getSwatchData(Filter $filter): array
    {
        // Get a map of filter item labels keyed by label
        $labels = array_flip(
            array_map(
Severity: Minor
Found in Model/Swatches/SwatchAttributeResolver.php - About 45 mins 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 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

        Client $client,
        RequestFactory $requestFactory,
        CollectionFactory $collectionFactory,
        CatalogConfig $catalogConfig,
        Visibility $visibility,
Severity: Minor
Found in Model/Catalog/Product/Recommendation/Context.php - About 45 mins to fix

    Function addParameter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function addParameter($parameter, $value, $separator = '|')
        {
            if (isset($this->parameters[$parameter])) {
                if ($value == null) {
                    unset($this->parameters[$parameter]);
    Severity: Minor
    Found in Model/Client/Request.php - About 45 mins 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

                responseQueryString.forEach((value, key) => {
                    if (false === uniqueQueryParams.has(key)) {
                        uniqueQueryParams.append(key, value);
                    }
                });
    Severity: Minor
    Found in view/frontend/web/js/navigation-form.js and 1 other location - About 40 mins to fix
    view/frontend/web/js/navigation-form.js on lines 429..433

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

    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

                origQueryString.forEach((value, key) => {
                    if (false === uniqueQueryParams.has(key)) {
                        uniqueQueryParams.append(key, value);
                    }
                });
    Severity: Minor
    Found in view/frontend/web/js/navigation-form.js and 1 other location - About 40 mins to fix
    view/frontend/web/js/navigation-form.js on lines 435..439

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

    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 aroundGetItems(Related $subject, Closure $proceed)
        {
            if (!$this->config->isRecommendationsEnabled(Config::RECOMMENDATION_TYPE_CROSSSELL)) {
                return $proceed();
            }
    Severity: Minor
    Found in Block/Catalog/Product/ProductList/Related/Plugin.php and 1 other location - About 40 mins to fix
    Block/Catalog/Product/ProductList/Upsell/Plugin.php on lines 34..49

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

    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 aroundGetItemCollection(Upsell $subject, Closure $proceed)
        {
            if (!$this->config->isRecommendationsEnabled(Config::RECOMMENDATION_TYPE_UPSELL)) {
                return $proceed();
            }
    Severity: Minor
    Found in Block/Catalog/Product/ProductList/Upsell/Plugin.php and 1 other location - About 40 mins to fix
    Block/Catalog/Product/ProductList/Related/Plugin.php on lines 33..48

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

    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

    Consider simplifying this complex logical expression.
    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 - About 40 mins to fix

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

              Config $config,
              Logger $log,
              ItemCollectionProviderInterface $originalProvider,
              CollectionFactory $collectionFactory,
              NavigationContext $navigationContext
      Severity: Minor
      Found in Model/Catalog/Layer/ItemCollectionProvider.php - About 35 mins to fix

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

                AttributeSlugResource $resource,
                AttributeSlugInterfaceFactory $entityFactory,
                CollectionFactory $collectionFactory,
                AttributeSlugSearchResultsInterfaceFactory $searchResultsFactory,
                CollectionProcessorInterface $collectionProcessor
        Severity: Minor
        Found in Model/AttributeSlugRepository.php - About 35 mins to fix

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

                  Layer $layer,
                  FacetType $facet,
                  ItemFactory $itemFactory,
                  StoreManager $storeManager,
                  Attribute $attribute = null
          Severity: Minor
          Found in Model/Catalog/Layer/Filter.php - About 35 mins to fix

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

                    TranslitUrl $translitUrl,
                    AttributeSlugRepositoryInterface $attributeSlugRepository,
                    AttributeSlugInterfaceFactory $attributeSlugFactory,
                    CacheInterface $cache,
                    SerializerInterface $serializer
            Severity: Minor
            Found in Model/Catalog/Layer/Url/Strategy/FilterSlugManager.php - About 35 mins to fix

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

                      Config $config,
                      Logger $log,
                      ResponseFactory $responseFactory,
                      EndpointManager $endpointManager,
                      Timer $timer
              Severity: Minor
              Found in Model/Client.php - About 35 mins to fix

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

                        UrlStrategyFactory $urlStrategyFactory,
                        MagentoHttpRequest $request,
                        CategoryRepositoryInterface $categoryRepository,
                        ExportHelper $exportHelper,
                        UrlModel $magentoUrl
                Severity: Minor
                Found in Model/Catalog/Layer/Url.php - About 35 mins to fix

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

                          Config $config,
                          LocaleFormat $localeFormat,
                          Registry $registry,
                          Context $context,
                          array $data = []
                  Severity: Minor
                  Found in Block/Autocomplete/FormMini.php - About 35 mins to fix

                    Function save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function save(AttributeSlugInterface $attributeSlug): AttributeSlugInterface
                        {
                            try {
                                //check for existing slugs with the same slug
                                try {
                    Severity: Minor
                    Found in Model/AttributeSlugRepository.php - About 35 mins 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 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function execute(Observer $observer)
                        {
                            $block = $observer->getData('block');
                            if (!$block instanceof Navigation) {
                                return;
                    Severity: Minor
                    Found in Model/Observer/NavigationHtmlOverride.php - About 35 mins 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 extractFilterValuesWhitelist has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public static function extractFilterValuesWhitelist(?string $filterList = null): array
                        {
                            if (empty($filterList)) {
                                return [];
                            }
                    Severity: Minor
                    Found in Model/ConfigAttributeProcessService.php - About 35 mins 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 addCategoryFilter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function addCategoryFilter($category)
                        {
                            $ids = [];
                            if (is_numeric($category)) {
                                $ids[] = $category;
                    Severity: Minor
                    Found in Model/Client/Request.php - About 35 mins 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

                    Severity
                    Category
                    Status
                    Source
                    Language