plugins/db/classes/yf_db.class.php

Summary

Maintainability
F
2 wks
Test Coverage

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

<?php

/**
 * Database abstraction layer.
 *
Severity: Major
Found in plugins/db/classes/yf_db.class.php - About 3 days to fix

    yf_db has 99 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class yf_db
    {
        /** @var string Type of database (default) */
        public $DB_TYPE = 'mysql';
        /** @var bool Switch caching on/off */
    Severity: Major
    Found in plugins/db/classes/yf_db.class.php - About 1 day to fix

      Function connect has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
      Open

          public function connect($db_host = '', $db_user = '', $db_pswd = null, $db_name = null, $force = false, $params = [])
          {
              if (is_array($db_host)) {
                  $params = $db_host;
                  $db_host = '';
      Severity: Minor
      Found in plugins/db/classes/yf_db.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

      Function _fix_data_safe has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

          public function _fix_data_safe($table, $data = [], $extra = [])
          {
              if ( ! $this->FIX_DATA_SAFE) {
                  return $data;
              }
      Severity: Minor
      Found in plugins/db/classes/yf_db.class.php - About 5 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function query has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
      Open

          public function &query($sql)
          {
              if ( ! $this->_connected && ! $this->connect()) {
                  return false;
              }
      Severity: Minor
      Found in plugins/db/classes/yf_db.class.php - About 5 hrs to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function query_fetch_all has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          public function query_fetch_all($sql, $key_name = null, $use_cache = true)
          {
              if ( ! strlen($sql)) {
                  return false;
              }
      Severity: Minor
      Found in plugins/db/classes/yf_db.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

      Method query has 74 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function &query($sql)
          {
              if ( ! $this->_connected && ! $this->connect()) {
                  return false;
              }
      Severity: Major
      Found in plugins/db/classes/yf_db.class.php - About 2 hrs to fix

        Method connect has 70 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function connect($db_host = '', $db_user = '', $db_pswd = null, $db_name = null, $force = false, $params = [])
            {
                if (is_array($db_host)) {
                    $params = $db_host;
                    $db_host = '';
        Severity: Major
        Found in plugins/db/classes/yf_db.class.php - About 2 hrs to fix

          Method _fix_data_safe has 60 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function _fix_data_safe($table, $data = [], $extra = [])
              {
                  if ( ! $this->FIX_DATA_SAFE) {
                      return $data;
                  }
          Severity: Major
          Found in plugins/db/classes/yf_db.class.php - About 2 hrs to fix

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

                public function query_fetch($sql, $use_cache = true, $assoc = true, $return_sql = false)
                {
                    if ( ! strlen($sql)) {
                        return false;
                    }
            Severity: Minor
            Found in plugins/db/classes/yf_db.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 query_fetch_all has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function query_fetch_all($sql, $key_name = null, $use_cache = true)
                {
                    if ( ! strlen($sql)) {
                        return false;
                    }
            Severity: Minor
            Found in plugins/db/classes/yf_db.class.php - About 1 hr to fix

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

                  public function query_fetch($sql, $use_cache = true, $assoc = true, $return_sql = false)
                  {
                      if ( ! strlen($sql)) {
                          return false;
                      }
              Severity: Minor
              Found in plugins/db/classes/yf_db.class.php - About 1 hr to fix

                Function es has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function es($string)
                    {
                        if ($string === null || $string === 'NULL') {
                            return 'NULL';
                        }
                Severity: Minor
                Found in plugins/db/classes/yf_db.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 get_deep_array has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function get_deep_array($sql, $max_levels = 0, $use_cache = true)
                    {
                        if ( ! strlen($sql)) {
                            return false;
                        }
                Severity: Minor
                Found in plugins/db/classes/yf_db.class.php - About 1 hr to fix

                  Method _save_query_revision has 33 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function _save_query_revision($method, $table, $params = [])
                      {
                          if (($allowed_methods = $this->QUERY_REVISIONS_METHODS)) {
                              if ( ! in_array($method, $allowed_methods)) {
                                  return false;
                  Severity: Minor
                  Found in plugins/db/classes/yf_db.class.php - About 1 hr to fix

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

                        public function insert($table, $data, $only_sql = false, $replace = false, $ignore = false, $on_duplicate_key_update = false, $extra = [])
                        {
                            if ($this->DB_REPLICATION_SLAVE && ! $only_sql) {
                                return false;
                            }
                    Severity: Minor
                    Found in plugins/db/classes/yf_db.class.php - About 1 hr to fix

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

                          public function insert($table, $data, $only_sql = false, $replace = false, $ignore = false, $on_duplicate_key_update = false, $extra = [])
                          {
                              if ($this->DB_REPLICATION_SLAVE && ! $only_sql) {
                                  return false;
                              }
                      Severity: Minor
                      Found in plugins/db/classes/yf_db.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 update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function update($table, $data, $where, $only_sql = false, $extra = [])
                          {
                              if ($this->DB_REPLICATION_SLAVE && ! $only_sql) {
                                  return false;
                              }
                      Severity: Minor
                      Found in plugins/db/classes/yf_db.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 get_deep_array has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function get_deep_array($sql, $max_levels = 0, $use_cache = true)
                          {
                              if ( ! strlen($sql)) {
                                  return false;
                              }
                      Severity: Minor
                      Found in plugins/db/classes/yf_db.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 _model_load has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function _model_load($name)
                          {
                              $main = main();
                              $model_class = $name . '_model';
                              $custom_storages = &$main->_custom_class_storages;
                      Severity: Minor
                      Found in plugins/db/classes/yf_db.class.php - About 1 hr to fix

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

                            public function _set_connect_params($db_host = '', $db_user = '', $db_pswd = null, $db_name = null, $force = false, $params = [])
                            {
                                if (is_array($db_host)) {
                                    $params = $db_host;
                                    $db_host = '';
                        Severity: Minor
                        Found in plugins/db/classes/yf_db.class.php - About 1 hr to fix

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

                              public function _model_load($name)
                              {
                                  $main = main();
                                  $model_class = $name . '_model';
                                  $custom_storages = &$main->_custom_class_storages;
                          Severity: Minor
                          Found in plugins/db/classes/yf_db.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 update_batch has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public function update_batch($table, $data, $index = null, $only_sql = false)
                              {
                                  if ($this->DB_REPLICATION_SLAVE && ! $only_sql) {
                                      return false;
                                  }
                          Severity: Minor
                          Found in plugins/db/classes/yf_db.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

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

                              public function insert_safe($table, $data, $only_sql = false, $replace = false, $ignore = false, $on_duplicate_key_update = false, $extra = [])
                          Severity: Major
                          Found in plugins/db/classes/yf_db.class.php - About 50 mins to fix

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

                                public function insert($table, $data, $only_sql = false, $replace = false, $ignore = false, $on_duplicate_key_update = false, $extra = [])
                            Severity: Major
                            Found in plugins/db/classes/yf_db.class.php - About 50 mins to fix

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

                                  public function _load_tables_with_sys_prefix()
                                  {
                                      if ($this->_need_sys_prefix) {
                                          return $this->_need_sys_prefix;
                                      }
                              Severity: Minor
                              Found in plugins/db/classes/yf_db.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 _set_connect_params has 6 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  public function _set_connect_params($db_host = '', $db_user = '', $db_pswd = null, $db_name = null, $force = false, $params = [])
                              Severity: Minor
                              Found in plugins/db/classes/yf_db.class.php - About 45 mins to fix

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

                                    public function __construct($db_type = '', $db_prefix = null, $db_replication_slave = null)
                                    {
                                        global $DEBUG;
                                
                                        $this->_load_tables_with_sys_prefix();
                                Severity: Minor
                                Found in plugins/db/classes/yf_db.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 get_2d has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    public function get_2d($sql, $use_cache = true)
                                    {
                                        if ( ! strlen($sql)) {
                                            return false;
                                        }
                                Severity: Minor
                                Found in plugins/db/classes/yf_db.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 connect has 6 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    public function connect($db_host = '', $db_user = '', $db_pswd = null, $db_name = null, $force = false, $params = [])
                                Severity: Minor
                                Found in plugins/db/classes/yf_db.class.php - About 45 mins to fix

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

                                      public function _init()
                                      {
                                          // Perform auto-connection to db if needed
                                          if (($this->AUTO_CONNECT || MAIN_TYPE == 'admin') && ! $this->NO_AUTO_CONNECT) {
                                              $this->connect();
                                  Severity: Minor
                                  Found in plugins/db/classes/yf_db.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 insert_on_duplicate_key_update has 5 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      public function insert_on_duplicate_key_update($table, $data, $only_sql = false, $replace = false, $extra = [])
                                  Severity: Minor
                                  Found in plugins/db/classes/yf_db.class.php - About 35 mins to fix

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

                                        public function update_safe($table, $data, $where, $only_sql = false, $extra = [])
                                    Severity: Minor
                                    Found in plugins/db/classes/yf_db.class.php - About 35 mins to fix

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

                                          public function insert_ignore($table, $data, $only_sql = false, $replace = false, $extra = [])
                                      Severity: Minor
                                      Found in plugins/db/classes/yf_db.class.php - About 35 mins to fix

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

                                            public function _update_query_log($log_id, $result, $query_time_start = 0, $warnings = null, $info = null)
                                        Severity: Minor
                                        Found in plugins/db/classes/yf_db.class.php - About 35 mins to fix

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

                                              public function update($table, $data, $where, $only_sql = false, $extra = [])
                                          Severity: Minor
                                          Found in plugins/db/classes/yf_db.class.php - About 35 mins to fix

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

                                                public function transaction($callback)
                                                {
                                                    if ( ! is_callable($callback)) {
                                                        return false;
                                                    }
                                            Severity: Minor
                                            Found in plugins/db/classes/yf_db.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->query($sql);
                                            Severity: Major
                                            Found in plugins/db/classes/yf_db.class.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                      return $this->query($sql);
                                              Severity: Major
                                              Found in plugins/db/classes/yf_db.class.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                        return $data;
                                                Severity: Major
                                                Found in plugins/db/classes/yf_db.class.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                          return str_replace(['\\', "\0", "\n", "\r", "'", '"', "\x1a"], ['\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'], $string);
                                                  Severity: Major
                                                  Found in plugins/db/classes/yf_db.class.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                return (int) $string;
                                                    Severity: Major
                                                    Found in plugins/db/classes/yf_db.class.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                              return $this->query_builder()->update_batch($table, $data, $index, $only_sql, $params);
                                                      Severity: Major
                                                      Found in plugins/db/classes/yf_db.class.php - About 30 mins to fix

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

                                                            public function _save_query_revision($method, $table, $params = [])
                                                            {
                                                                if (($allowed_methods = $this->QUERY_REVISIONS_METHODS)) {
                                                                    if ( ! in_array($method, $allowed_methods)) {
                                                                        return false;
                                                        Severity: Minor
                                                        Found in plugins/db/classes/yf_db.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 _set_connect_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                        Open

                                                            public function _set_connect_params($db_host = '', $db_user = '', $db_pswd = null, $db_name = null, $force = false, $params = [])
                                                            {
                                                                if (is_array($db_host)) {
                                                                    $params = $db_host;
                                                                    $db_host = '';
                                                        Severity: Minor
                                                        Found in plugins/db/classes/yf_db.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 _execute_shutdown_queries has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                        Open

                                                            public function _execute_shutdown_queries()
                                                            {
                                                                if ( ! $this->USE_SHUTDOWN_QUERIES || isset($this->_shutdown_executed)) {
                                                                    return false;
                                                                }
                                                        Severity: Minor
                                                        Found in plugins/db/classes/yf_db.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 multi_query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                        Open

                                                            public function multi_query($sql = [])
                                                            {
                                                                if ( ! $this->_connected && ! $this->connect()) {
                                                                    return false;
                                                                }
                                                        Severity: Minor
                                                        Found in plugins/db/classes/yf_db.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 escape_val has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                        Open

                                                            public function escape_val($data)
                                                            {
                                                                if ($data === null || $data === 'NULL') {
                                                                    return 'NULL';
                                                                } elseif (is_array($data)) {
                                                        Severity: Minor
                                                        Found in plugins/db/classes/yf_db.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 _real_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                        Open

                                                            public function _real_name($name)
                                                            {
                                                                $name = trim($name);
                                                                if ( ! strlen($name)) {
                                                                    return false;
                                                        Severity: Minor
                                                        Found in plugins/db/classes/yf_db.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 _fix_table_name has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                        Open

                                                            public function _fix_table_name($name = '')
                                                            {
                                                                $name = trim($name);
                                                                if ( ! strlen($name)) {
                                                                    return false;
                                                        Severity: Minor
                                                        Found in plugins/db/classes/yf_db.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 _mysql_escape_mimic has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                        Open

                                                            public function _mysql_escape_mimic($string)
                                                            {
                                                                if (is_array($string)) {
                                                                    return array_map([$this, __FUNCTION__], $string);
                                                                }
                                                        Severity: Minor
                                                        Found in plugins/db/classes/yf_db.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 plugins/db/classes/yf_db.class.php and 1 other location - About 1 hr to fix
                                                        classes/yf_main.class.php on lines 1524..1535

                                                        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

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

                                                                    if ($use_cache && $this->ALLOW_CACHE_QUERIES && ! $this->NO_CACHE && ! isset($storage[$sql])) {
                                                                        $storage[$sql] = $data;
                                                                        // Permanently turn off queries cache (and free some memory) if case of limit reached
                                                                        if ($this->CACHE_QUERIES_LIMIT && count((array) $storage) > $this->CACHE_QUERIES_LIMIT) {
                                                                            $this->ALLOW_CACHE_QUERIES = false;
                                                        Severity: Minor
                                                        Found in plugins/db/classes/yf_db.class.php and 1 other location - About 30 mins to fix
                                                        plugins/db/classes/yf_db.class.php on lines 1054..1061

                                                        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

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

                                                                if ($use_cache && $this->ALLOW_CACHE_QUERIES && ! $this->NO_CACHE && ! isset($storage[$sql])) {
                                                                    $storage[$sql] = $data;
                                                                    // Permanently turn off queries cache (and free some memory) if case of limit reached
                                                                    if ($this->CACHE_QUERIES_LIMIT && count((array) $storage) > $this->CACHE_QUERIES_LIMIT) {
                                                                        $this->ALLOW_CACHE_QUERIES = false;
                                                        Severity: Minor
                                                        Found in plugins/db/classes/yf_db.class.php and 1 other location - About 30 mins to fix
                                                        plugins/db/classes/yf_db.class.php on lines 842..849

                                                        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