plugins/tpl/classes/yf_tpl.class.php

Summary

Maintainability
F
1 wk
Test Coverage

File yf_tpl.class.php has 746 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Stadard Framework template engine.
 *
Severity: Major
Found in plugins/tpl/classes/yf_tpl.class.php - About 1 day to fix

    Function _get_template_file has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring.
    Open

        public function _get_template_file($file_name = '', $force_storage = '', $JUST_CHECK_IF_EXISTS = false, $RETURN_TEMPLATE_PATH = false)
        {
            $string = false;
            $NOT_FOUND = false;
            $storage = 'inline';
    Severity: Minor
    Found in plugins/tpl/classes/yf_tpl.class.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

    Function init_graphics has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
    Open

        public function init_graphics()
        {
            $init_type = MAIN_TYPE;
            // Do not remove this!
            $this->_init_global_tags();
    Severity: Minor
    Found in plugins/tpl/classes/yf_tpl.class.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

    Method _get_template_file has 131 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function _get_template_file($file_name = '', $force_storage = '', $JUST_CHECK_IF_EXISTS = false, $RETURN_TEMPLATE_PATH = false)
        {
            $string = false;
            $NOT_FOUND = false;
            $storage = 'inline';
    Severity: Major
    Found in plugins/tpl/classes/yf_tpl.class.php - About 5 hrs to fix

      yf_tpl has 39 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class yf_tpl
      {
          /** @var string @conf_skip Path to the templates (including current theme path) */
          public $TPL_PATH = '';
          /** @var string default template name */
      Severity: Minor
      Found in plugins/tpl/classes/yf_tpl.class.php - About 5 hrs to fix

        Method init_graphics has 107 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function init_graphics()
            {
                $init_type = MAIN_TYPE;
                // Do not remove this!
                $this->_init_global_tags();
        Severity: Major
        Found in plugins/tpl/classes/yf_tpl.class.php - About 4 hrs to fix

          Function _init has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              public function _init()
              {
                  // Needed to ensure backtracking still works on big templates (extended from 1 000 000 on 26kb stpl js() parsing)
                  ini_set('pcre.backtrack_limit', '10000000');
          
          
          Severity: Minor
          Found in plugins/tpl/classes/yf_tpl.class.php - About 2 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 _init has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function _init()
              {
                  // Needed to ensure backtracking still works on big templates (extended from 1 000 000 on 26kb stpl js() parsing)
                  ini_set('pcre.backtrack_limit', '10000000');
          
          
          Severity: Major
          Found in plugins/tpl/classes/yf_tpl.class.php - About 2 hrs to fix

            Method parse has 51 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function parse($name, $replace = [], $params = [])
                {
                    $name = strtolower(trim($name));
                    // Support for the driver name in prefix, example: "twig:user/account", "smarty:user/account"
                    if (strpos($name, ':') !== false) {
            Severity: Major
            Found in plugins/tpl/classes/yf_tpl.class.php - About 2 hrs to fix

              Method _get_cached_paths has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function _get_cached_paths()
                  {
                      $cache_name = __FUNCTION__ . '_' . MAIN_TYPE;
                      if (isset($this->$cache_name)) {
                          return $this->$cache_name;
              Severity: Minor
              Found in plugins/tpl/classes/yf_tpl.class.php - About 1 hr to fix

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

                    public function parse($name, $replace = [], $params = [])
                    {
                        $name = strtolower(trim($name));
                        // Support for the driver name in prefix, example: "twig:user/account", "smarty:user/account"
                        if (strpos($name, ':') !== false) {
                Severity: Minor
                Found in plugins/tpl/classes/yf_tpl.class.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 _i18n_wrapper has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function _i18n_wrapper($input = '', $replace = [])
                    {
                        if ( ! strlen($input)) {
                            return '';
                        }
                Severity: Minor
                Found in plugins/tpl/classes/yf_tpl.class.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 _i18n_wrapper has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function _i18n_wrapper($input = '', $replace = [])
                    {
                        if ( ! strlen($input)) {
                            return '';
                        }
                Severity: Minor
                Found in plugins/tpl/classes/yf_tpl.class.php - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                                  if (in_array($_storage, ['app', 'project', 'framework'])) {
                                      $_theme = $_storage == 'framework' ? MAIN_TYPE : $theme;
                                      if (isset($paths[$_storage][$_theme])) {
                                          $file_path = $paths[$_storage][$_theme];
                                      }
                  Severity: Major
                  Found in plugins/tpl/classes/yf_tpl.class.php - About 40 mins to fix

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

                        public function _parse_set_debug_info($name = '', $replace = [], $params = [], $string = '', $stpl_time_start)
                    Severity: Minor
                    Found in plugins/tpl/classes/yf_tpl.class.php - About 35 mins to fix

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

                          public function _process_var_filters($text = '', $filters = '')
                          {
                              if (is_string($filters) && strpos($filters, '|') !== false) {
                                  $filters = explode('|', $filters);
                              }
                      Severity: Minor
                      Found in plugins/tpl/classes/yf_tpl.class.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 _url_wrapper has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function _url_wrapper($params = [])
                          {
                              // Try to process method params (string like attrib1=value1;attrib2=value2)
                              if (is_string($params) && strlen($params)) {
                                  // Url like this: /object/action/id
                      Severity: Minor
                      Found in plugins/tpl/classes/yf_tpl.class.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

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

                              if (preg_match('/(?P<text>.+?)["\']{1},[\s\t]*%(?P<args>[a-z]+.+)$/ims', $input, $m)) {
                                  foreach (explode(';%', $m['args']) as $arg) {
                                      $attr_name = $attr_val = '';
                                      if (false !== strpos($arg, '=')) {
                                          list($attr_name, $attr_val) = explode('=', trim($arg));
                      Severity: Major
                      Found in plugins/tpl/classes/yf_tpl.class.php and 1 other location - About 6 hrs to fix
                      plugins/locale/admin_modules/locale_editor/yf_locale_editor_collect.class.php on lines 231..244

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

                      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

                          public function _process_var_filters($text = '', $filters = '')
                          {
                              if (is_string($filters) && strpos($filters, '|') !== false) {
                                  $filters = explode('|', $filters);
                              }
                      Severity: Major
                      Found in plugins/tpl/classes/yf_tpl.class.php and 1 other location - About 3 hrs to fix
                      plugins/table2/classes/yf_table2.class.php on lines 907..923

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

                      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

                                      } elseif (in_array($_storage, ['app_inherit', 'site_inherit']) && $this->_INHERITED_SKIN) {
                                          $_theme = $this->_INHERITED_SKIN;
                                          $s = substr($_storage, 0, -strlen('_inherit'));
                                          if (isset($paths[$s][$_theme])) {
                                              $file_path = $paths[$s][$_theme];
                      Severity: Minor
                      Found in plugins/tpl/classes/yf_tpl.class.php and 1 other location - About 45 mins to fix
                      plugins/tpl/classes/yf_tpl.class.php on lines 677..683

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

                      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

                                      } elseif (in_array($_storage, ['app_inherit2', 'site_inherit2']) && $this->_INHERITED_SKIN2) {
                                          $_theme = $this->_INHERITED_SKIN2;
                                          $s = substr($_storage, 0, -strlen('_inherit2'));
                                          if (isset($paths[$s][$_theme])) {
                                              $file_path = $paths[$s][$_theme];
                      Severity: Minor
                      Found in plugins/tpl/classes/yf_tpl.class.php and 1 other location - About 45 mins to fix
                      plugins/tpl/classes/yf_tpl.class.php on lines 671..677

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

                      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