MPOS/php-mpos

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

Summary

Maintainability
F
6 days
Test Coverage

Function createTemplateCodeFrame has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
Open

    public function createTemplateCodeFrame($content = '', $cache = false)
    {
        $plugins_string = '';
        // include code for plugins
        if (!$cache) {
Severity: Minor
Found in include/smarty/libs/sysplugins/smarty_internal_template.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_internal_template.php has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Smarty Internal Plugin Template
 *
 * This file contains the Smarty template engine
Severity: Minor
Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 6 hrs to fix

    Function decodeProperties has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        public function decodeProperties($properties, $cache = false)
        {
            $this->has_nocache_code = $properties['has_nocache_code'];
            $this->properties['nocache_hash'] = $properties['nocache_hash'];
            if (isset($properties['cache_lifetime'])) {
    Severity: Minor
    Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 5 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 createTemplateCodeFrame has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function createTemplateCodeFrame($content = '', $cache = false)
        {
            $plugins_string = '';
            // include code for plugins
            if (!$cache) {
    Severity: Major
    Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 2 hrs to fix

      Method decodeProperties has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function decodeProperties($properties, $cache = false)
          {
              $this->has_nocache_code = $properties['has_nocache_code'];
              $this->properties['nocache_hash'] = $properties['nocache_hash'];
              if (isset($properties['cache_lifetime'])) {
      Severity: Minor
      Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 2 hrs to fix

        Function compileTemplateSource has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            public function compileTemplateSource()
            {
                if (!$this->source->recompiled) {
                    $this->properties['file_dependency'] = array();
                    if ($this->source->components) {
        Severity: Minor
        Found in include/smarty/libs/sysplugins/smarty_internal_template.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 getSubTemplate has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope)
            {
                // already in template cache?
                if ($this->smarty->allow_ambiguous_resources) {
                    $_templateId = Smarty_Resource::getUniqueTemplateName($this, $template) . $cache_id . $compile_id;
        Severity: Minor
        Found in include/smarty/libs/sysplugins/smarty_internal_template.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 __get has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __get($property_name)
            {
                switch ($property_name) {
                    case 'source':
                        if (strlen($this->template_resource) == 0) {
        Severity: Minor
        Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 1 hr to fix

          Method getSubTemplate has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function getSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope)
              {
                  // already in template cache?
                  if ($this->smarty->allow_ambiguous_resources) {
                      $_templateId = Smarty_Resource::getUniqueTemplateName($this, $template) . $cache_id . $compile_id;
          Severity: Minor
          Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                    if ($this->properties['version'] != Smarty::SMARTY_VERSION) {
                        $is_valid = false;
                    } elseif (((!$cache && $this->smarty->compile_check && empty($this->compiled->_properties) && !$this->compiled->isCompiled) || $cache && ($this->smarty->compile_check === true || $this->smarty->compile_check === Smarty::COMPILECHECK_ON)) && !empty($this->properties['file_dependency'])) {
                        foreach ($this->properties['file_dependency'] as $_file_to_check) {
                            if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'php') {
            Severity: Critical
            Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 1 hr to fix

              Method compileTemplateSource has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function compileTemplateSource()
                  {
                      if (!$this->source->recompiled) {
                          $this->properties['file_dependency'] = array();
                          if ($this->source->components) {
              Severity: Minor
              Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 1 hr to fix

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

                    public function __get($property_name)
                    {
                        switch ($property_name) {
                            case 'source':
                                if (strlen($this->template_resource) == 0) {
                Severity: Minor
                Found in include/smarty/libs/sysplugins/smarty_internal_template.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 _count has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function _count($value)
                    {
                        if (is_array($value) === true || $value instanceof Countable) {
                            return count($value);
                        } elseif ($value instanceof IteratorAggregate) {
                Severity: Minor
                Found in include/smarty/libs/sysplugins/smarty_internal_template.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 setupInlineSubTemplate has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function setupInlineSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope, $hash)
                Severity: Major
                Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 1 hr to fix

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

                      public function __construct($template_resource, $smarty, $_parent = null, $_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null)
                  Severity: Major
                  Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 50 mins to fix

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

                        public function getSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope)
                    Severity: Major
                    Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 50 mins to fix

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

                          public function mustCompile()
                          {
                              if (!$this->source->exists) {
                                  if ($this->parent instanceof Smarty_Internal_Template) {
                                      $parent_resource = " in '$this->parent->template_resource}'";
                      Severity: Minor
                      Found in include/smarty/libs/sysplugins/smarty_internal_template.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 setupInlineSubTemplate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function setupInlineSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope, $hash)
                          {
                              $tpl = new $this->smarty->template_class($template, $this->smarty, $this, $cache_id, $compile_id, $caching, $cache_lifetime);
                              $tpl->properties['nocache_hash']  = $hash;
                              // get variables from calling scope
                      Severity: Minor
                      Found in include/smarty/libs/sysplugins/smarty_internal_template.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 ($this->mustCompile === null) {
                                  $this->mustCompile = (!$this->source->uncompiled && ($this->smarty->force_compile || $this->source->recompiled || $this->compiled->timestamp === false ||
                                          ($this->smarty->compile_check && $this->compiled->timestamp < $this->source->timestamp)));
                              }
                      Severity: Major
                      Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 40 mins to fix

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

                            public function createLocalArrayVariable($tpl_var, $nocache = false, $scope = Smarty::SCOPE_LOCAL)
                            {
                                if (!isset($this->tpl_vars[$tpl_var])) {
                                    $this->tpl_vars[$tpl_var] = new Smarty_variable(array(), $nocache, $scope);
                                } else {
                        Severity: Minor
                        Found in include/smarty/libs/sysplugins/smarty_internal_template.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

                        Avoid too many return statements within this method.
                        Open

                                    return count($value);
                        Severity: Major
                        Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                      return iterator_count($value);
                          Severity: Major
                          Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

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

                              Avoid too many return statements within this method.
                              Open

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

                                Avoid too many return statements within this method.
                                Open

                                                    return $this->smarty->$property_name;
                                Severity: Major
                                Found in include/smarty/libs/sysplugins/smarty_internal_template.php - About 30 mins to fix

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

                                      public function &getScope($scope)
                                      {
                                          if ($scope == Smarty::SCOPE_PARENT && !empty($this->parent)) {
                                              return $this->parent->tpl_vars;
                                          } elseif ($scope == Smarty::SCOPE_ROOT && !empty($this->parent)) {
                                  Severity: Minor
                                  Found in include/smarty/libs/sysplugins/smarty_internal_template.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

                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                          if ($parent_scope == Smarty::SCOPE_LOCAL) {
                                              $tpl->tpl_vars = $this->tpl_vars;
                                              $tpl->tpl_vars['smarty'] = clone $this->tpl_vars['smarty'];
                                          } elseif ($parent_scope == Smarty::SCOPE_PARENT) {
                                              $tpl->tpl_vars = &$this->tpl_vars;
                                  Severity: Major
                                  Found in include/smarty/libs/sysplugins/smarty_internal_template.php and 1 other location - About 2 hrs to fix
                                  include/smarty/libs/sysplugins/smarty_internal_template.php on lines 305..316

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

                                  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

                                  Identical blocks of code found in 2 locations. Consider refactoring.
                                  Open

                                          if ($parent_scope == Smarty::SCOPE_LOCAL) {
                                              $tpl->tpl_vars = $this->tpl_vars;
                                              $tpl->tpl_vars['smarty'] = clone $this->tpl_vars['smarty'];
                                          } elseif ($parent_scope == Smarty::SCOPE_PARENT) {
                                              $tpl->tpl_vars = &$this->tpl_vars;
                                  Severity: Major
                                  Found in include/smarty/libs/sysplugins/smarty_internal_template.php and 1 other location - About 2 hrs to fix
                                  include/smarty/libs/sysplugins/smarty_internal_template.php on lines 264..275

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

                                  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

                                  There are no issues that match your filters.

                                  Category
                                  Status