MPOS/php-mpos

View on GitHub
include/smarty/libs/sysplugins/smarty_resource.php

Summary

Maintainability
F
4 days
Test Coverage

Function buildFilepath has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
Open

    protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
    {
        $file = $source->name;
        if ($source instanceof Smarty_Config_Source) {
            $_directories = $source->smarty->getConfigDir();
Severity: Minor
Found in include/smarty/libs/sysplugins/smarty_resource.php - About 1 day 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

File smarty_resource.php has 413 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Smarty Resource Plugin
 *
 * @package Smarty
Severity: Minor
Found in include/smarty/libs/sysplugins/smarty_resource.php - About 5 hrs to fix

    Method buildFilepath has 104 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
        {
            $file = $source->name;
            if ($source instanceof Smarty_Config_Source) {
                $_directories = $source->smarty->getConfigDir();
    Severity: Major
    Found in include/smarty/libs/sysplugins/smarty_resource.php - About 4 hrs to fix

      Function load has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function load(Smarty $smarty, $type)
          {
              // try smarty's cache
              if (isset($smarty->_resource_handlers[$type])) {
                  return $smarty->_resource_handlers[$type];
      Severity: Minor
      Found in include/smarty/libs/sysplugins/smarty_resource.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 load has 52 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function load(Smarty $smarty, $type)
          {
              // try smarty's cache
              if (isset($smarty->_resource_handlers[$type])) {
                  return $smarty->_resource_handlers[$type];
      Severity: Major
      Found in include/smarty/libs/sysplugins/smarty_resource.php - About 2 hrs to fix

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

            protected function normalizePath($_path, $ds=true)
            {
                if ($ds) {
                    // don't we all just love windows?
                    $_path = str_replace('\\', '/', $_path);
        Severity: Minor
        Found in include/smarty/libs/sysplugins/smarty_resource.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 populateCompiledFilepath has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template)
            {
                $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null;
                $_filepath = $compiled->source->uid;
                // if use_sub_dirs, break file into directories
        Severity: Minor
        Found in include/smarty/libs/sysplugins/smarty_resource.php - About 1 hr to fix

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

              public static function source(Smarty_Internal_Template $_template=null, Smarty $smarty=null, $template_resource=null)
              {
                  if ($_template) {
                      $smarty = $_template->smarty;
                      $template_resource = $_template->template_resource;
          Severity: Minor
          Found in include/smarty/libs/sysplugins/smarty_resource.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 __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function __construct(Smarty_Resource $handler, Smarty $smarty, $resource, $type, $name, $unique_resource)
          Severity: Minor
          Found in include/smarty/libs/sysplugins/smarty_resource.php - About 45 mins to fix

            Avoid too many return statements within this method.
            Open

                        return $smarty->_resource_handlers[$type] = self::$resources['stream'];
            Severity: Major
            Found in include/smarty/libs/sysplugins/smarty_resource.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                          return $file;
              Severity: Major
              Found in include/smarty/libs/sysplugins/smarty_resource.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return $smarty->_resource_handlers[$type] = self::$resources[$type];
                Severity: Major
                Found in include/smarty/libs/sysplugins/smarty_resource.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return self::load($smarty, $type);
                  Severity: Major
                  Found in include/smarty/libs/sysplugins/smarty_resource.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return $_return;
                    Severity: Major
                    Found in include/smarty/libs/sysplugins/smarty_resource.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                      return $_filepath;
                      Severity: Major
                      Found in include/smarty/libs/sysplugins/smarty_resource.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                return false;
                        Severity: Major
                        Found in include/smarty/libs/sysplugins/smarty_resource.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return $smarty->_resource_handlers[$type] = self::$resources[$type];
                          Severity: Major
                          Found in include/smarty/libs/sysplugins/smarty_resource.php - About 30 mins to fix

                            Function populateCompiledFilepath has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function populateCompiledFilepath(Smarty_Template_Compiled $compiled, Smarty_Internal_Template $_template)
                                {
                                    $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null;
                                    $_filepath = $compiled->source->uid;
                                    // if use_sub_dirs, break file into directories
                            Severity: Minor
                            Found in include/smarty/libs/sysplugins/smarty_resource.php - About 25 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

                            There are no issues that match your filters.

                            Category
                            Status