classes/yf_main.class.php

Summary

Maintainability
F
2 wks
Test Coverage

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

<?php

/**
 * Core main class.
 *
Severity: Major
Found in classes/yf_main.class.php - About 4 days to fix

    yf_main has 92 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class yf_main
    {
        /**
         * @var string Type of initialization @conf_skip
         *    - user  (for user section)
    Severity: Major
    Found in classes/yf_main.class.php - About 1 day to fix

      Function load_class_file has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
      Open

          public function load_class_file($class_name = '', $custom_path = '', $force_storage = '')
          {
              if (empty($class_name) || $class_name == 'main') {
                  return false;
              }
      Severity: Minor
      Found in classes/yf_main.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 load_class_file has 186 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function load_class_file($class_name = '', $custom_path = '', $force_storage = '')
          {
              if (empty($class_name) || $class_name == 'main') {
                  return false;
              }
      Severity: Major
      Found in classes/yf_main.class.php - About 7 hrs to fix

        Function init_constants has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
        Open

            public function init_constants()
            {
                $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                // Save current working directory (to restore it later when execute shutdown functions)
                $this->_CWD = getcwd();
        Severity: Minor
        Found in classes/yf_main.class.php - About 7 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_constants has 119 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function init_constants()
            {
                $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                // Save current working directory (to restore it later when execute shutdown functions)
                $this->_CWD = getcwd();
        Severity: Major
        Found in classes/yf_main.class.php - About 4 hrs to fix

          Function init_server_id has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              public function init_server_id()
              {
                  $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                  $servers = $this->get_data('servers');
                  $this->SERVER_ID = 0;
          Severity: Minor
          Found in classes/yf_main.class.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 _do_rewrite has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              public function _do_rewrite()
              {
                  $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                  if ($this->is_console() || MAIN_TYPE_ADMIN || ! module_conf('tpl', 'REWRITE_MODE')) {
                      return false;
          Severity: Minor
          Found in classes/yf_main.class.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 call_class_method has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              public function call_class_method($class_name = '', $custom_path = '', $method_name = '', $method_params = '', $tpl_name = '', $silent = false, $use_cache = false, $cache_ttl = -1, $cache_key_override = '')
              {
                  if ( ! strlen($class_name) || ! strlen($method_name)) {
                      return false;
                  }
          Severity: Minor
          Found in classes/yf_main.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

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

              public function _after_init_hook()
              {
                  $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                  $this->events->fire('main.after_init_begin');
                  $this->_check_site_maintenance();
          Severity: Minor
          Found in classes/yf_main.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

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

              public function init_class($class_name, $custom_path = '', $params = '')
              {
                  $class_name = $this->get_class_name($class_name);
                  if (isset($this->modules[$class_name]) && is_object($this->modules[$class_name])) {
                      return $this->modules[$class_name];
          Severity: Minor
          Found in classes/yf_main.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

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

              public function _find_site($sites_dir = '')
              {
                  $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                  if ( ! $sites_dir) {
                      $try_paths = [
          Severity: Minor
          Found in classes/yf_main.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

          Function getset has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getset($name, callable $func, $ttl = 0, array $params = [])
              {
                  if ( ! is_string($name) || ! $name) {
                      return null;
                  }
          Severity: Minor
          Found in classes/yf_main.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 __construct has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function __construct($type = 'user', $no_db_connect = false, $auto_init_all = false, $_conf = [])
              {
                  if ( ! isset($this->_time_start)) {
                      $this->_time_start = microtime(true);
                  }
          Severity: Major
          Found in classes/yf_main.class.php - About 2 hrs to fix

            Function _preload_plugins_list has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
            Open

                public function _preload_plugins_list($force = false)
                {
                    $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                    if (isset($this->_plugins) && ! $force) {
                        return $this->_plugins;
            Severity: Minor
            Found in classes/yf_main.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 _do_rewrite has 55 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function _do_rewrite()
                {
                    $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                    if ($this->is_console() || MAIN_TYPE_ADMIN || ! module_conf('tpl', 'REWRITE_MODE')) {
                        return false;
            Severity: Major
            Found in classes/yf_main.class.php - About 2 hrs to fix

              Method _find_site has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function _find_site($sites_dir = '')
                  {
                      $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                      if ( ! $sites_dir) {
                          $try_paths = [
              Severity: Minor
              Found in classes/yf_main.class.php - About 1 hr to fix

                Method call_class_method has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function call_class_method($class_name = '', $custom_path = '', $method_name = '', $method_params = '', $tpl_name = '', $silent = false, $use_cache = false, $cache_ttl = -1, $cache_key_override = '')
                    {
                        if ( ! strlen($class_name) || ! strlen($method_name)) {
                            return false;
                        }
                Severity: Minor
                Found in classes/yf_main.class.php - About 1 hr to fix

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

                      public function _after_init_hook()
                      {
                          $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                          $this->events->fire('main.after_init_begin');
                          $this->_check_site_maintenance();
                  Severity: Minor
                  Found in classes/yf_main.class.php - About 1 hr to fix

                    Method init_class has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function init_class($class_name, $custom_path = '', $params = '')
                        {
                            $class_name = $this->get_class_name($class_name);
                            if (isset($this->modules[$class_name]) && is_object($this->modules[$class_name])) {
                                return $this->modules[$class_name];
                    Severity: Minor
                    Found in classes/yf_main.class.php - About 1 hr to fix

                      Method get_data has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function get_data($name = '', $force_ttl = 0, $params = [])
                          {
                              DEBUG_MODE && $time_start = microtime(true);
                              if (empty($name)) {
                                  return null;
                      Severity: Minor
                      Found in classes/yf_main.class.php - About 1 hr to fix

                        Method _preload_plugins_list has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function _preload_plugins_list($force = false)
                            {
                                $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                if (isset($this->_plugins) && ! $force) {
                                    return $this->_plugins;
                        Severity: Minor
                        Found in classes/yf_main.class.php - About 1 hr to fix

                          Method init_server_id has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function init_server_id()
                              {
                                  $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                  $servers = $this->get_data('servers');
                                  $this->SERVER_ID = 0;
                          Severity: Minor
                          Found in classes/yf_main.class.php - About 1 hr to fix

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

                                public function is_https()
                                {
                                    return (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && strtolower($_SERVER['HTTPS']) != 'off')
                                        || (isset($_SERVER['SSL_PROTOCOL']) && $_SERVER['SSL_PROTOCOL'])
                                        // Non-standard header used by Microsoft applications and load-balancers:
                            Severity: Minor
                            Found in classes/yf_main.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 init_auth has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function init_auth()
                                {
                                    $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                    $this->events->fire('main.before_auth');
                                    if (defined('SITE_DEFAULT_PAGE')) {
                            Severity: Minor
                            Found in classes/yf_main.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 set_module_conf has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function set_module_conf($module_name = '', &$MODULE_OBJ, $params = '')
                                {
                                    // Stop here if project config not set or some other things missing
                                    if (empty($module_name) || ! is_object($MODULE_OBJ)) {
                                        return false;
                            Severity: Minor
                            Found in classes/yf_main.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 _load_data_handlers has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function _load_data_handlers()
                                {
                                    $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                    if ($this->_data_handlers_loaded) {
                                        return false;
                            Severity: Minor
                            Found in classes/yf_main.class.php - About 1 hr to fix

                              Method getset has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function getset($name, callable $func, $ttl = 0, array $params = [])
                                  {
                                      if ( ! is_string($name) || ! $name) {
                                          return null;
                                      }
                              Severity: Minor
                              Found in classes/yf_main.class.php - About 1 hr to fix

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

                                    public function init_files()
                                    {
                                        $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                        $include_files = [];
                                        $required_files = [];
                                Severity: Minor
                                Found in classes/yf_main.class.php - About 1 hr to fix

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

                                      public function init_auth()
                                      {
                                          $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                          $this->events->fire('main.before_auth');
                                          if (defined('SITE_DEFAULT_PAGE')) {
                                  Severity: Minor
                                  Found in classes/yf_main.class.php - About 1 hr to fix

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

                                        public function _replace_core_paths($str)
                                        {
                                            if (strpos($str, '_PATH') === false) {
                                                return $str;
                                            }
                                    Severity: Minor
                                    Found in classes/yf_main.class.php - About 1 hr to fix

                                      Method call_class_method has 9 arguments (exceeds 4 allowed). Consider refactoring.
                                      Open

                                          public function call_class_method($class_name = '', $custom_path = '', $method_name = '', $method_params = '', $tpl_name = '', $silent = false, $use_cache = false, $cache_ttl = -1, $cache_key_override = '')
                                      Severity: Major
                                      Found in classes/yf_main.class.php - About 1 hr to fix

                                        Method _find_site_path_best_match has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                        Open

                                            public function _find_site_path_best_match($sites, $server_ip, $server_port, $server_host)
                                            {
                                                $sip = explode('.', $server_ip);
                                                $sh = array_reverse(explode('.', $server_host));
                                                $sh2 = explode('.', $server_host);
                                        Severity: Minor
                                        Found in classes/yf_main.class.php - About 1 hr to fix

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

                                              public function __construct($type = 'user', $no_db_connect = false, $auto_init_all = false, $_conf = [])
                                              {
                                                  if ( ! isset($this->_time_start)) {
                                                      $this->_time_start = microtime(true);
                                                  }
                                          Severity: Minor
                                          Found in classes/yf_main.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 include_module has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              public function include_module($path_to_module = '', $is_required = false)
                                              {
                                                  if (DEBUG_MODE) {
                                                      $_time_start = microtime(true);
                                                  }
                                          Severity: Minor
                                          Found in classes/yf_main.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 include_module has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                                          Open

                                              public function include_module($path_to_module = '', $is_required = false)
                                              {
                                                  if (DEBUG_MODE) {
                                                      $_time_start = microtime(true);
                                                  }
                                          Severity: Minor
                                          Found in classes/yf_main.class.php - About 1 hr to fix

                                            Method _execute has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                            Open

                                                public function _execute($class_name = '', $method_name = '', $method_params = '', $tpl_name = '', $silent = false, $use_cache = false, $cache_ttl = -1, $cache_key_override = '')
                                            Severity: Major
                                            Found in classes/yf_main.class.php - About 1 hr to fix

                                              Method execute has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                              Open

                                                  public function execute($class_name = '', $method_name = '', $method_params = '', $tpl_name = '', $silent = false, $use_cache = false, $cache_ttl = -1, $cache_key_override = '')
                                              Severity: Major
                                              Found in classes/yf_main.class.php - About 1 hr to fix

                                                Method exec_cached has 8 arguments (exceeds 4 allowed). Consider refactoring.
                                                Open

                                                    public function exec_cached($class_name = '', $method_name = '', $method_params = '', $tpl_name = '', $silent = false, $use_cache = true, $cache_ttl = -1, $cache_key_override = '')
                                                Severity: Major
                                                Found in classes/yf_main.class.php - About 1 hr to fix

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

                                                      public function init_files()
                                                      {
                                                          $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                                          $include_files = [];
                                                          $required_files = [];
                                                  Severity: Minor
                                                  Found in classes/yf_main.class.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

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

                                                      public function init_db()
                                                      {
                                                          $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                                          $this->events->fire('main.before_db');
                                                          // Check if current object/action not required db connection
                                                  Severity: Minor
                                                  Found in classes/yf_main.class.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

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

                                                      public function init_site_id()
                                                      {
                                                          $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                                          if ( ! conf('SITE_ID')) {
                                                              $site_id = 1;
                                                  Severity: Minor
                                                  Found in classes/yf_main.class.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 _init_cur_user_info has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                                  Open

                                                      public function _init_cur_user_info(&$obj)
                                                      {
                                                          $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), []];
                                                          if (MAIN_TYPE_ADMIN) {
                                                              $obj->USER_ID = $_GET['user_id'];
                                                  Severity: Minor
                                                  Found in classes/yf_main.class.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

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

                                                      public function _get_exec_cache_name($class_name = '', $custom_path = '', $method_name = '', $method_params = '', $tpl_name = '')
                                                  Severity: Minor
                                                  Found in classes/yf_main.class.php - About 35 mins to fix

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

                                                        public function get_data($name = '', $force_ttl = 0, $params = [])
                                                        {
                                                            DEBUG_MODE && $time_start = microtime(true);
                                                            if (empty($name)) {
                                                                return null;
                                                    Severity: Minor
                                                    Found in classes/yf_main.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 spider_detection has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function spider_detection()
                                                        {
                                                            $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                                            if ( ! $this->SPIDERS_DETECTION) {
                                                                return false;
                                                    Severity: Minor
                                                    Found in classes/yf_main.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 _framework_destruct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                    Open

                                                        public function _framework_destruct()
                                                        {
                                                            $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                                            // Restore startup working directory
                                                            chdir($this->_CWD);
                                                    Severity: Minor
                                                    Found in classes/yf_main.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

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                return $this->modules[$class_name];
                                                    Severity: Major
                                                    Found in classes/yf_main.class.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                              return null;
                                                      Severity: Major
                                                      Found in classes/yf_main.class.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                    return YF_PREFIX . $class_name;
                                                        Severity: Major
                                                        Found in classes/yf_main.class.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                  return $loaded_class_name;
                                                          Severity: Major
                                                          Found in classes/yf_main.class.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                                return false;
                                                            Severity: Major
                                                            Found in classes/yf_main.class.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                      return $result;
                                                              Severity: Major
                                                              Found in classes/yf_main.class.php - About 30 mins to fix

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

                                                                    public function init_server_health()
                                                                    {
                                                                        $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                                                        // Server health result (needed to correctly self turn off faulty box from frontend requests)
                                                                        if ( ! $this->is_console() && $this->SERVER_HEALTH_CHECK && $this->SERVER_HEALTH_FILE && file_exists($this->SERVER_HEALTH_FILE)) {
                                                                Severity: Minor
                                                                Found in classes/yf_main.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

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

                                                                    public function init_session()
                                                                    {
                                                                        $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                                                        $this->events->fire('main.before_session');
                                                                        $skip = false;
                                                                Severity: Minor
                                                                Found in classes/yf_main.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

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

                                                                    public function _load_data_handlers()
                                                                    {
                                                                        $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                                                        if ($this->_data_handlers_loaded) {
                                                                            return false;
                                                                Severity: Minor
                                                                Found in classes/yf_main.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

                                                                    public function trace()
                                                                    {
                                                                        $trace = [];
                                                                        foreach (debug_backtrace() as $k => $v) {
                                                                            if ( ! $k) {
                                                                Severity: Major
                                                                Found in classes/yf_main.class.php and 1 other location - About 1 hr to fix
                                                                plugins/db/classes/yf_db.class.php on lines 1901..1912

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

                                                                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 init_conf_functions()
                                                                    {
                                                                        $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                                                        $path = dirname(__DIR__) . '/functions/yf_conf.php';
                                                                        if (file_exists($path)) {
                                                                Severity: Minor
                                                                Found in classes/yf_main.class.php and 1 other location - About 45 mins to fix
                                                                classes/yf_main.class.php on lines 462..469

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

                                                                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 init_main_functions()
                                                                    {
                                                                        $this->PROFILING && $this->_timing[] = [microtime(true), __CLASS__, __FUNCTION__, $this->trace_string(), func_get_args()];
                                                                        $path = dirname(__DIR__) . '/functions/yf_aliases.php';
                                                                        if (file_exists($path)) {
                                                                Severity: Minor
                                                                Found in classes/yf_main.class.php and 1 other location - About 45 mins to fix
                                                                classes/yf_main.class.php on lines 450..457

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

                                                                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 execute($class_name = '', $method_name = '', $method_params = '', $tpl_name = '', $silent = false, $use_cache = false, $cache_ttl = -1, $cache_key_override = '')
                                                                    {
                                                                        return $this->_execute($class_name, $method_name, $method_params, $tpl_name, $silent, $use_cache, $cache_ttl, $cache_key_override);
                                                                    }
                                                                Severity: Minor
                                                                Found in classes/yf_main.class.php and 1 other location - About 30 mins to fix
                                                                classes/yf_main.class.php on lines 1370..1373

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

                                                                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 exec_cached($class_name = '', $method_name = '', $method_params = '', $tpl_name = '', $silent = false, $use_cache = true, $cache_ttl = -1, $cache_key_override = '')
                                                                    {
                                                                        return $this->_execute($class_name, $method_name, $method_params, $tpl_name, $silent, $use_cache, $cache_ttl, $cache_key_override);
                                                                    }
                                                                Severity: Minor
                                                                Found in classes/yf_main.class.php and 1 other location - About 30 mins to fix
                                                                classes/yf_main.class.php on lines 1353..1356

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

                                                                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