ecoco/magento_profiler

View on GitHub
app/code/community/Ecocode/Profiler/Model/Collector/RequestDataCollector.php

Summary

Maintainability
D
2 days
Test Coverage

File RequestDataCollector.php has 445 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Class Ecocode_Profiler_Model_Collector_RequestDataCollector
 */

    Ecocode_Profiler_Model_Collector_RequestDataCollector has 45 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Ecocode_Profiler_Model_Collector_RequestDataCollector
        extends Ecocode_Profiler_Model_Collector_AbstractDataCollector
    {
        protected $messages = [];
    
    

      The class Ecocode_Profiler_Model_Collector_RequestDataCollector has an overall complexity of 90 which is very high. The configured complexity threshold is 50.
      Open

      class Ecocode_Profiler_Model_Collector_RequestDataCollector
          extends Ecocode_Profiler_Model_Collector_AbstractDataCollector
      {
          protected $messages = [];
      
      

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

          protected function collectSessionData()
          {
              $namespaceData  = [];
              $storeData      = [];
              $rawSessionData = $this->getRawSession();

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

          public function collect(Mage_Core_Controller_Request_Http $request, Mage_Core_Controller_Response_Http $response, \Exception $exception = null)
          {
              $responseHeaders = $this->collectResponseHeaders($response);
              // attributes are serialized and as they can be anything, they need to be converted to strings.
              $requestAttributes = $this->collectRequestAttributes($request);

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

            protected function collectSessionData()
            {
                $namespaceData  = [];
                $storeData      = [];
                $rawSessionData = $this->getRawSession();

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

              public function captureFlashMessages()
              {
                  $messages = [];
                  foreach ($this->getRawSession() as $namespace => $data) {
                      if (!isset($data['messages'])) {

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

              protected function parseController($controller)
              {
                  if (is_object($controller)) {
                      /** @var Mage_Core_Controller_Varien_Front $controller */
          
          

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

                protected function detectStatusCode(Mage_Core_Controller_Response_Http $response)
                {
                    $statusCode = $response->getHttpResponseCode();
                    foreach ($response->getHeaders() as $header) {
                        if (substr($header['name'], 0, 5) === 'Http/') {

            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 parseController has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function parseController($controller)
                {
                    if (is_object($controller)) {
                        /** @var Mage_Core_Controller_Varien_Front $controller */
            
            

            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

            Missing class import via use statement (line '503', column '41').
            Open

                        $controllerReflection = new \ReflectionClass($controller);

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '603', column '22').
            Open

                    $class = new ReflectionClass('Mage_Core_Model_App');

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '287', column '20').
            Open

                    return new Ecocode_Profiler_Model_Http_ParameterBag($this->data['request_query']);

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '542', column '22').
            Open

                    $class = new ReflectionClass('Mage_Core_Controller_Request_Http');

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '307', column '20').
            Open

                    return new Ecocode_Profiler_Model_Http_ParameterBag($this->data['request_attributes']);

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '297', column '20').
            Open

                    return new Ecocode_Profiler_Model_Http_ParameterBag($this->data['request_server']);

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '489', column '45').
            Open

                                $actionReflection = new \ReflectionMethod(

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '292', column '20').
            Open

                    return new Ecocode_Profiler_Model_Http_HeaderBag($this->data['request_headers']);

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '312', column '20').
            Open

                    return new Ecocode_Profiler_Model_Http_ResponseHeaderBag($this->data['response_headers']);

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '282', column '20').
            Open

                    return new Ecocode_Profiler_Model_Http_ParameterBag($this->data['request_request']);

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Missing class import via use statement (line '302', column '20').
            Open

                    return new Ecocode_Profiler_Model_Http_ParameterBag($this->data['request_cookies']);

            MissingImport

            Since: 2.7.0

            Importing all external classes in a file through use statements makes them clearly visible.

            Example

            function make() {
                return new \stdClass();
            }

            Source http://phpmd.org/rules/cleancode.html#MissingImport

            Avoid excessively long class names like Ecocode_Profiler_Model_Collector_RequestDataCollector. Keep class name length under 40.
            Open

            class Ecocode_Profiler_Model_Collector_RequestDataCollector
                extends Ecocode_Profiler_Model_Collector_AbstractDataCollector
            {
                protected $messages = [];
            
            

            LongClassName

            Since: 2.9

            Detects when classes or interfaces are declared with excessively long names.

            Example

            class ATooLongClassNameThatHintsAtADesignProblem {
            
            }
            
            interface ATooLongInterfaceNameThatHintsAtADesignProblem {
            
            }

            Source https://phpmd.org/rules/naming.html#longclassname

            There are no issues that match your filters.

            Category
            Status