app/resto/core/addons/STAC.php

Summary

Maintainability
F
3 days
Test Coverage

File STAC.php has 429 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/*
 * Copyright 2022 Jérôme Gasperi
 *
 * Licensed under the Apache License, version 2.0 (the "License");
Severity: Minor
Found in app/resto/core/addons/STAC.php - About 6 hrs to fix

    Function setCatalogsLinksFromFacet has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

        private function setCatalogsLinksFromFacet($params)
        {
            $nbOfSegments = count($this->segments);
            $leafValue = $this->segments[$nbOfSegments - 1];
            
    Severity: Minor
    Found in app/resto/core/addons/STAC.php - About 4 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 load has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        private function load($params = array())
        {
            $nbOfSegments = count($this->segments);
    
            // Root
    Severity: Minor
    Found in app/resto/core/addons/STAC.php - About 3 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 setCatalogsLinksFromFacet has 86 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function setCatalogsLinksFromFacet($params)
        {
            $nbOfSegments = count($this->segments);
            $leafValue = $this->segments[$nbOfSegments - 1];
            
    Severity: Major
    Found in app/resto/core/addons/STAC.php - About 3 hrs to fix

      Method load has 68 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function load($params = array())
          {
              $nbOfSegments = count($this->segments);
      
              // Root
      Severity: Major
      Found in app/resto/core/addons/STAC.php - About 2 hrs to fix

        Function setThemesLinks has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            private function setThemesLinks()
            {
                $this->title = $this->segments[1];
                $this->description = 'Collections for theme **' . $this->segments[1] . '**';
        
        
        Severity: Minor
        Found in app/resto/core/addons/STAC.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 setThemesLinks has 36 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function setThemesLinks()
            {
                $this->title = $this->segments[1];
                $this->description = 'Collections for theme **' . $this->segments[1] . '**';
        
        
        Severity: Minor
        Found in app/resto/core/addons/STAC.php - About 1 hr to fix

          Method getChildren has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getChildren($params)
              {
                  $childs = array();
          
                  // Initialize router to process each children individually
          Severity: Minor
          Found in app/resto/core/addons/STAC.php - About 1 hr to fix

            Function getChildren has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public function getChildren($params)
                {
                    $childs = array();
            
                    // Initialize router to process each children individually
            Severity: Minor
            Found in app/resto/core/addons/STAC.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 search has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function search($params, $body)
                {
                    if ($this->context->method === 'POST') {
                        $params = $this->jsonQueryToKVP($body);
                    }
            Severity: Minor
            Found in app/resto/core/addons/STAC.php - About 55 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

            Avoid too many return statements within this method.
            Open

                        return RestoLogUtil::httpError(404);
            Severity: Major
            Found in app/resto/core/addons/STAC.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return $this;
              Severity: Major
              Found in app/resto/core/addons/STAC.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return RestoLogUtil::httpError(404);
                Severity: Major
                Found in app/resto/core/addons/STAC.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return RestoLogUtil::httpError(404);
                  Severity: Major
                  Found in app/resto/core/addons/STAC.php - About 30 mins to fix

                    There are no issues that match your filters.

                    Category
                    Status