ecoco/magento_profiler

View on GitHub

Showing 84 of 241 total issues

Function _addData has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _addData($data, $scope, $forceReload = false)
    {
        $source = debug_backtrace()[1]['function'];
        if (isset($this->sourceMap[$source])) {
            $source = $this->sourceMap[$source];
Severity: Minor
Found in app/code/community/Ecocode/Profiler/overwrite/MageCoreModelTranslate.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

Function _isInheritanceConflict has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected function _isInheritanceConflict($classes)
    {
        $count   = count($classes);
        $classes = array_reverse($classes);
        for ($i = 1; $i < $count; $i++) {
Severity: Minor
Found in app/code/community/Ecocode/Profiler/Helper/Rewrite.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

Function getCategory has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    protected static function getCategory($timerName)
    {
        if (isset(self::$sectionMap[$timerName])) {
            return self::CATEGORY_SECTION;
        }
Severity: Minor
Found in app/code/community/Ecocode/Profiler/overwrite/VarienProfiler.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

Function formatArgs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    public function formatArgs($args)
    {
        $result = [];
        foreach ($args as $key => $item) {
            if ('object' === $item[0]) {
Severity: Minor
Found in app/code/community/Ecocode/Profiler/Helper/Code.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

Method find has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function find($ip, $url, $limit, $method, $start = null, $end = null, $statusCode = null)
Severity: Major
Found in app/code/community/Ecocode/Profiler/Model/Profiler/FileStorage.php - About 50 mins to fix

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

        public function getMenuBlocks()
        {
            if (!$this->getProfile()) {
                return [];
            }
    Severity: Minor
    Found in app/code/community/Ecocode/Profiler/Block/Profiler/Sidebar/Menu.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 getVersion has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getVersion()
        {
            if (self::$version === null && class_exists('Mage') && $config = Mage::getConfig()) {
                //try to load from magento
                $config = $config->getModuleConfig('Ecocode_Profiler');
    Severity: Minor
    Found in app/code/community/Ecocode/Profiler/Helper/Data.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 getUserConfig has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function getUserConfig($asArray = false)
        {
            if (!$this->userConfig || $asArray) {
                $userConfigFile = $this->getUserConfigFile();
    
    
    Severity: Minor
    Found in app/code/community/Ecocode/Profiler/Model/Config.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 createProfileFromData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function createProfileFromData($token, $data, $parent = null)
        {
            $profile = new Ecocode_Profiler_Model_Profile($token);
            $profile->setIp($data['ip']);
            $profile->setMethod($data['method']);
    Severity: Minor
    Found in app/code/community/Ecocode/Profiler/Model/Profiler/FileStorage.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 find has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function find($ip, $url, $limit, $method, $start, $end)
    Severity: Minor
    Found in app/code/community/Ecocode/Profiler/Model/Profiler.php - About 45 mins to fix

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

          public function write(Ecocode_Profiler_Model_Profile $profile)
          {
              $file = $this->getFilename($profile->getToken());
      
              $profileIndexed = is_file($file);
      Severity: Minor
      Found in app/code/community/Ecocode/Profiler/Model/Profiler/FileStorage.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 collect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          public function collect(Mage_Core_Controller_Request_Http $request, Mage_Core_Controller_Response_Http $response, \Exception $exception = null)
          {
              $stats = [
                  'load'      => 0,
                  'loop_load' => 0,

      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 find has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function find($ip, $url, $limit, $method, $start = null, $end = null);
      Severity: Minor
      Found in app/code/community/Ecocode/Profiler/Model/Profiler/StorageInterface.php - About 45 mins to fix

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

            public function getCookies($format = self::COOKIES_FLAT)
            {
                if (!in_array($format, [self::COOKIES_FLAT, self::COOKIES_ARRAY])) {
                    throw new \InvalidArgumentException(sprintf('Format "%s" invalid (%s).', $format, implode(', ', [self::COOKIES_FLAT, self::COOKIES_ARRAY])));
                }
        Severity: Minor
        Found in app/code/community/Ecocode/Profiler/Model/Http/ResponseHeaderBag.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

        Consider simplifying this complex logical expression.
        Open

        if ((!isset($_SERVER['ALLOW_PROFILER']) || $_SERVER['ALLOW_PROFILER'] !== '1') && (
                isset($_SERVER['HTTP_CLIENT_IP'])
                || isset($_SERVER['HTTP_X_FORWARDED_FOR'])
                || !(in_array(@$_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1']) || php_sapi_name() === 'cli-server')
            )
        Severity: Major
        Found in dev.php - About 40 mins to fix

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

              public function getRequestJsonData()
              {
                  $eventList = $this->getCollector()->getEvents();
                  $events = [];
                  foreach ($eventList as $name => $event) {
          Severity: Minor
          Found in app/code/community/Ecocode/Profiler/Block/Collector/Time/Panel.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 beforeToHtml has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              public function beforeToHtml(Varien_Event_Observer $observer)
              {
                  /** @var Mage_Core_Block_Abstract $block */
                  $block = $observer->getEvent()->getData('block');
                  $id    = uniqid();

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

              public function translate($args)
              {
                  $argsCopy             = $args;
                  $this->currentMessage = [
                      'locale' => $this->_locale,
          Severity: Minor
          Found in app/code/community/Ecocode/Profiler/overwrite/MageCoreModelTranslate.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 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 getCacheControlHeader has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function getCacheControlHeader()
              {
                  $parts = [];
                  ksort($this->cacheControl);
                  foreach ($this->cacheControl as $key => $value) {
          Severity: Minor
          Found in app/code/community/Ecocode/Profiler/Model/Http/HeaderBag.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