modxcms/revolution

View on GitHub
core/model/smarty/sysplugins/smarty_internal_runtime_tplfunction.php

Summary

Maintainability
C
1 day
Test Coverage

Function addTplFuncToCache has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    public function addTplFuncToCache(Smarty_Internal_Template $tpl, $_name, $_function)
    {
        $funcParam = $tpl->tplFunctions[ $_name ];
        if (is_file($funcParam[ 'compiled_filepath' ])) {
            // read compiled file
Severity: Minor
Found in core/model/smarty/sysplugins/smarty_internal_runtime_tplfunction.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

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

    public function callTemplateFunction(Smarty_Internal_Template $tpl, $name, $params, $nocache)
    {
        $funcParam = isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
            (isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : null);
        if (isset($funcParam)) {

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

    public function addTplFuncToCache(Smarty_Internal_Template $tpl, $_name, $_function)
    {
        $funcParam = $tpl->tplFunctions[ $_name ];
        if (is_file($funcParam[ 'compiled_filepath' ])) {
            // read compiled file

    Method callTemplateFunction has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function callTemplateFunction(Smarty_Internal_Template $tpl, $name, $params, $nocache)
        {
            $funcParam = isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
                (isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : null);
            if (isset($funcParam)) {

      Avoid deeply nested control flow statements.
      Open

                              if ($content) {
                                  // check if we must update file dependency
                                  if (!preg_match("/'{$funcParam['uid']}'(.*?)'nocache_hash'/", $content, $match2)) {
                                      $content = preg_replace("/('file_dependency'(.*?)\()/", "\\1{$match1[0]}", $content);
                                  }
      Severity: Major
      Found in core/model/smarty/sysplugins/smarty_internal_runtime_tplfunction.php - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status