CaffGeek/MBACNationals

View on GitHub
Web.Admin/2014/wordpress/wp-includes/wp-db.php

Summary

Maintainability
F
3 days
Test Coverage

File wp-db.php has 430 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WordPress DB Class
 *
 * Original code from {@link http://php.justinvincent.com Justin Vincent (justin@visunet.ie)}
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/wp-db.php - About 6 hrs to fix

    wpdb has 32 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class wpdb {
    
        /**
         * Whether to show SQL/DB errors
         *
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/wp-db.php - About 4 hrs to fix

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

          function get_results($query = null, $output = OBJECT) {
              $this->func_call = "\$db->get_results(\"$query\", $output)";
      
              if ( $query )
                  $this->query($query);
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/wp-db.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 query has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          function query($query) {
              if ( ! $this->ready )
                  return false;
      
              // filter the query, if filters are available
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/wp-db.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 query has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function query($query) {
              if ( ! $this->ready )
                  return false;
      
              // filter the query, if filters are available
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/wp-db.php - About 1 hr to fix

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

            function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
                register_shutdown_function(array(&$this, "__destruct"));
        
                if ( WP_DEBUG )
                    $this->show_errors();
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/wp-db.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 __construct has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
                register_shutdown_function(array(&$this, "__destruct"));
        
                if ( WP_DEBUG )
                    $this->show_errors();
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/wp-db.php - About 1 hr to fix

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

              function update($table, $data, $where, $format = null, $where_format = null) {
                  if ( !is_array( $where ) )
                      return false;
          
                  $formats = $format = (array) $format;
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/wp-db.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_results has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              function get_results($query = null, $output = OBJECT) {
                  $this->func_call = "\$db->get_results(\"$query\", $output)";
          
                  if ( $query )
                      $this->query($query);
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/wp-db.php - About 1 hr to fix

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

                function print_error($str = '') {
                    global $EZSQL_ERROR;
            
                    if (!$str) $str = mysql_error($this->dbh);
                    $EZSQL_ERROR[] = array ('query' => $this->last_query, 'error_str' => $str);
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/wp-db.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 _escape has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                function _escape($data) {
                    if ( is_array($data) ) {
                        foreach ( (array) $data as $k => $v ) {
                            if ( is_array($v) )
                                $data[$k] = $this->_escape( $v );
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/wp-db.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 escape has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                function escape($data) {
                    if ( is_array($data) ) {
                        foreach ( (array) $data as $k => $v ) {
                            if ( is_array($v) )
                                $data[$k] = $this->escape( $v );
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/wp-db.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 update has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                function update($table, $data, $where, $format = null, $where_format = null) {
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/wp-db.php - About 35 mins to fix

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

                  function get_col_info($info_type = 'name', $col_offset = -1) {
                      if ( $this->col_info ) {
                          if ( $col_offset == -1 ) {
                              $i = 0;
                              foreach( (array) $this->col_info as $col ) {
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/wp-db.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 get_caller has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  function get_caller() {
                      // requires PHP 4.3+
                      if ( !is_callable('debug_backtrace') )
                          return '';
              
              
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/wp-db.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 get_row has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  function get_row($query = null, $output = OBJECT, $y = 0) {
                      $this->func_call = "\$db->get_row(\"$query\",$output,$y)";
                      if ( $query )
                          $this->query($query);
                      else
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/wp-db.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->last_result[$y] ? array_values(get_object_vars($this->last_result[$y])) : null;
              Severity: Major
              Found in Web.Admin/2014/wordpress/wp-includes/wp-db.php - About 30 mins to fix

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

                        foreach ( (array) array_keys($data) as $field ) {
                            if ( !empty($format) )
                                $form = ( $form = array_shift($formats) ) ? $form : $format[0];
                            elseif ( isset($this->field_types[$field]) )
                                $form = $this->field_types[$field];
                Severity: Major
                Found in Web.Admin/2014/wordpress/wp-includes/wp-db.php and 1 other location - About 1 hr to fix
                Web.Admin/2014/wordpress/wp-includes/wp-db.php on lines 817..825

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

                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

                        foreach ( (array) array_keys($where) as $field ) {
                            if ( !empty($where_format) )
                                $form = ( $form = array_shift($where_formats) ) ? $form : $where_format[0];
                            elseif ( isset($this->field_types[$field]) )
                                $form = $this->field_types[$field];
                Severity: Major
                Found in Web.Admin/2014/wordpress/wp-includes/wp-db.php and 1 other location - About 1 hr to fix
                Web.Admin/2014/wordpress/wp-includes/wp-db.php on lines 806..814

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

                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

                    function escape($data) {
                        if ( is_array($data) ) {
                            foreach ( (array) $data as $k => $v ) {
                                if ( is_array($v) )
                                    $data[$k] = $this->escape( $v );
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/wp-db.php and 1 other location - About 55 mins to fix
                Web.Admin/2014/wordpress/wp-includes/wp-db.php on lines 483..496

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

                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

                    function _escape($data) {
                        if ( is_array($data) ) {
                            foreach ( (array) $data as $k => $v ) {
                                if ( is_array($v) )
                                    $data[$k] = $this->_escape( $v );
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/wp-db.php and 1 other location - About 55 mins to fix
                Web.Admin/2014/wordpress/wp-includes/wp-db.php on lines 506..519

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

                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