MPOS/php-mpos

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

Summary

Maintainability
F
1 wk
Test Coverage

Function compileTag has a Cognitive Complexity of 235 (exceeds 5 allowed). Consider refactoring.
Open

    public function compileTag($tag, $args, $parameter = array())
    {
        // $args contains the attributes parsed and compiled by the lexer/parser
        // assume that tag does compile into code, but creates no HTML output
        $this->has_code = true;

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

    public function compileTag($tag, $args, $parameter = array())
    {
        // $args contains the attributes parsed and compiled by the lexer/parser
        // assume that tag does compile into code, but creates no HTML output
        $this->has_code = true;

    File smarty_internal_templatecompilerbase.php has 473 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     * Smarty Internal Plugin Smarty Template Compiler Base
     *

      Function compileTemplate has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          public function compileTemplate(Smarty_Internal_Template $template, $nocache = false)
          {
              if (empty($template->properties['nocache_hash'])) {
                  $template->properties['nocache_hash'] = $this->nocache_hash;
              } else {

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

          public function getPlugin($plugin_name, $plugin_type)
          {
              $function = null;
              if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
                  if (isset($this->template->required_plugins['nocache'][$plugin_name][$plugin_type])) {

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

          public function getPluginFromDefaultHandler($tag, $plugin_type)
          {
              $callback = null;
              $script = null;
              $cacheable = true;

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

          public function compileTemplate(Smarty_Internal_Template $template, $nocache = false)
          {
              if (empty($template->properties['nocache_hash'])) {
                  $template->properties['nocache_hash'] = $this->nocache_hash;
              } else {

        Function processNocacheCode has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            public function processNocacheCode($content, $is_code)
            {
                // If the template is not evaluated and we have a nocache section and or a nocache tag
                if ($is_code && !empty($content)) {
                    // generate replacement code

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

            public function getPlugin($plugin_name, $plugin_type)
            {
                $function = null;
                if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
                    if (isset($this->template->required_plugins['nocache'][$plugin_name][$plugin_type])) {

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

              public function trigger_template_error($args = null, $line = null)
              {
                  // get template source line which has error
                  if (!isset($line)) {
                      $line = $this->lex->line;

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

              public function getPluginFromDefaultHandler($tag, $plugin_type)
              {
                  $callback = null;
                  $script = null;
                  $cacheable = true;

            Method trigger_template_error has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function trigger_template_error($args = null, $line = null)
                {
                    // get template source line which has error
                    if (!isset($line)) {
                        $line = $this->lex->line;

              Consider simplifying this complex logical expression.
              Open

                          if ((!($this->template->source->recompiled) || $this->forceNocache) && $this->template->caching && !$this->suppressNocacheProcessing &&
                              ($this->nocache || $this->tag_nocache)
                          ) {
                              $this->template->has_nocache_code = true;
                              $_output = addcslashes($content, '\'\\');
              Severity: Major
              Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 40 mins to fix

                Method callTagCompiler has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null)
                Severity: Minor
                Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 35 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                                  return $this->callTagCompiler('private_' . $plugin_type . '_plugin', $args, $parameter, $tag, $function);
                  Severity: Major
                  Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                                    return $this->default_handler_plugins[$plugin_type][$tag][0][0]->$function[1]($new_args, $this);
                    Severity: Major
                    Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                                  return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter, $tag);
                      Severity: Major
                      Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                        Avoid too many return statements within this method.
                        Open

                                                        return call_user_func_array($function, array($new_args, $this));
                        Severity: Major
                        Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                                          return call_user_func_array($function, array($new_args, $this));
                          Severity: Major
                          Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                        return $plugin($new_args, $this->smarty);
                            Severity: Major
                            Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                      return $function($args, $this);
                              Severity: Major
                              Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                                return $function($new_args, $this);
                                Severity: Major
                                Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                          return call_user_func_array($function, array($args, $this));
                                  Severity: Major
                                  Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                            return $plugin($args, $this->smarty);
                                    Severity: Major
                                    Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                              return $this->trigger_template_error('unallowed closing tag methode "' . $methode . '" in registered object "' . $base_tag . '"', $this->lex->taglineno);
                                      Severity: Major
                                      Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                            return $this->callTagCompiler('private_registered_block', $args, $parameter, $tag);
                                        Severity: Major
                                        Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                                  return $this->trigger_template_error('unallowed methode "' . $methode . '" in registered object "' . $tag . '"', $this->lex->taglineno);
                                          Severity: Major
                                          Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                                        return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter, $tag);
                                            Severity: Major
                                            Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                                              return $plugin_object->compile($args, $this);
                                              Severity: Major
                                              Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                                return $this->smarty->registered_plugins[$plugin_type][$tag][0][0]->$function[1]($new_args, $this);
                                                Severity: Major
                                                Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                                          return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag, $methode);
                                                  Severity: Major
                                                  Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                                return $plugin_object->compile($args, $this);
                                                    Severity: Major
                                                    Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                                      return $function($new_args, $this);
                                                      Severity: Major
                                                      Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                            return $this->callTagCompiler('private_block_plugin', $args, $parameter, $tag, $function);
                                                        Severity: Major
                                                        Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                                  return $this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][0][0]->$function[1]($args, $this);
                                                          Severity: Major
                                                          Found in include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php - About 30 mins to fix

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

                                                                    } else {
                                                                        if (isset($this->template->required_plugins['compiled'][$plugin_name][$plugin_type])) {
                                                                            $function = $this->template->required_plugins['compiled'][$plugin_name][$plugin_type]['function'];
                                                                        } elseif (isset($this->template->required_plugins['nocache'][$plugin_name][$plugin_type])) {
                                                                            $this->template->required_plugins['compiled'][$plugin_name][$plugin_type] = $this->template->required_plugins['nocache'][$plugin_name][$plugin_type];
                                                            include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php on lines 583..597

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

                                                            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

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

                                                                    if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
                                                                        if (isset($this->template->required_plugins['nocache'][$plugin_name][$plugin_type])) {
                                                                            $function = $this->template->required_plugins['nocache'][$plugin_name][$plugin_type]['function'];
                                                                        } elseif (isset($this->template->required_plugins['compiled'][$plugin_name][$plugin_type])) {
                                                                            $this->template->required_plugins['nocache'][$plugin_name][$plugin_type] = $this->template->required_plugins['compiled'][$plugin_name][$plugin_type];
                                                            include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php on lines 590..597

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

                                                            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

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

                                                                                if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
                                                                                    $this->template->required_plugins['nocache'][$tag][$plugin_type]['file'] = $script;
                                                                                    $this->template->required_plugins['nocache'][$tag][$plugin_type]['function'] = $callback;
                                                                                } else {
                                                                                    $this->template->required_plugins['compiled'][$tag][$plugin_type]['file'] = $script;
                                                            include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php on lines 610..616

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

                                                            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

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

                                                                        if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
                                                                            $this->template->required_plugins['nocache'][$plugin_name][$plugin_type]['file'] = $file;
                                                                            $this->template->required_plugins['nocache'][$plugin_name][$plugin_type]['function'] = $function;
                                                                        } else {
                                                                            $this->template->required_plugins['compiled'][$plugin_name][$plugin_type]['file'] = $file;
                                                            include/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php on lines 650..656

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

                                                            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

                                                                            foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
                                                                                $exp_token = $this->parser->yyTokenName[$token];
                                                                                if (isset($this->lex->smarty_token_names[$exp_token])) {
                                                                                    // token type from lexer
                                                                                    $expect[] = '"' . $this->lex->smarty_token_names[$exp_token] . '"';
                                                            include/smarty/libs/sysplugins/smarty_internal_config_file_compiler.php on lines 126..135

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

                                                            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