CaffGeek/MBACNationals

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

Summary

Maintainability
F
2 wks
Test Coverage

Function dbDelta has a Cognitive Complexity of 140 (exceeds 5 allowed). Consider refactoring.
Open

function dbDelta($queries, $execute = true) {
    global $wpdb;

    // Separate individual queries into an array
    if( !is_array($queries) ) {
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 2 days 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

File upgrade.php has 1025 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WordPress Upgrade API
 *
 * Most of the functions are pluggable and can be overwritten
Severity: Major
Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 2 days to fix

    Function upgrade_230 has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
    Open

    function upgrade_230() {
        global $wp_current_db_version, $wpdb;
    
        if ( $wp_current_db_version < 5200 ) {
            populate_roles_230();
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 1 day to fix

    Cognitive Complexity

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

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

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

    Further reading

    Function upgrade_160 has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
    Open

    function upgrade_160() {
        global $wpdb, $wp_current_db_version;
    
        populate_roles_160();
    
    
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.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 upgrade_230 has 133 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function upgrade_230() {
        global $wp_current_db_version, $wpdb;
    
        if ( $wp_current_db_version < 5200 ) {
            populate_roles_230();
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 5 hrs to fix

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

      function dbDelta($queries, $execute = true) {
          global $wpdb;
      
          // Separate individual queries into an array
          if( !is_array($queries) ) {
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 5 hrs to fix

        Function make_site_theme_from_default has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
        Open

        function make_site_theme_from_default($theme_name, $template) {
            $site_dir = WP_CONTENT_DIR . "/themes/$template";
            $default_dir = WP_CONTENT_DIR . '/themes/default';
        
            // Copy files from the default theme to the site theme.
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 4 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 make_site_theme_from_oldschool has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        function make_site_theme_from_oldschool($theme_name, $template) {
            $home_path = get_home_path();
            $site_dir = WP_CONTENT_DIR . "/themes/$template";
        
            if (! file_exists("$home_path/index.php"))
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.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 wp_install_defaults has 88 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function wp_install_defaults($user_id) {
            global $wpdb;
        
            // Default category
            $cat_name = __('Uncategorized');
        Severity: Major
        Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 3 hrs to fix

          Function upgrade_210 has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

          function upgrade_210() {
              global $wpdb, $wp_current_db_version;
          
              if ( $wp_current_db_version < 3506 ) {
                  // Update status and type.
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.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 upgrade_100 has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          function upgrade_100() {
              global $wpdb;
          
              // Get the title and ID of every post, post_name to check if it already has a value
              $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''");
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.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 upgrade_130 has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          function upgrade_130() {
              global $wpdb;
          
              // Remove extraneous backslashes.
              $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts");
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.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 upgrade_160 has 61 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function upgrade_160() {
              global $wpdb, $wp_current_db_version;
          
              populate_roles_160();
          
          
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 2 hrs to fix

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

            function upgrade_all() {
                global $wp_current_db_version, $wp_db_version, $wp_rewrite;
                $wp_current_db_version = __get_option('db_version');
            
                // We are up-to-date.  Nothing to do.
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.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 upgrade_130 has 53 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function upgrade_130() {
                global $wpdb;
            
                // Remove extraneous backslashes.
                $posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts");
            Severity: Major
            Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 2 hrs to fix

              Method upgrade_all has 46 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function upgrade_all() {
                  global $wp_current_db_version, $wp_db_version, $wp_rewrite;
                  $wp_current_db_version = __get_option('db_version');
              
                  // We are up-to-date.  Nothing to do.
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 1 hr to fix

                Method make_site_theme_from_oldschool has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function make_site_theme_from_oldschool($theme_name, $template) {
                    $home_path = get_home_path();
                    $site_dir = WP_CONTENT_DIR . "/themes/$template";
                
                    if (! file_exists("$home_path/index.php"))
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 1 hr to fix

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

                  function make_site_theme_from_default($theme_name, $template) {
                      $site_dir = WP_CONTENT_DIR . "/themes/$template";
                      $default_dir = WP_CONTENT_DIR . '/themes/default';
                  
                      // Copy files from the default theme to the site theme.
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 1 hr to fix

                    Method upgrade_100 has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function upgrade_100() {
                        global $wpdb;
                    
                        // Get the title and ID of every post, post_name to check if it already has a value
                        $posts = $wpdb->get_results("SELECT ID, post_title, post_name FROM $wpdb->posts WHERE post_name = ''");
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 1 hr to fix

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

                      function get_alloptions_110() {
                          global $wpdb;
                          if ($options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options")) {
                              foreach ($options as $option) {
                                  // "When trying to design a foolproof system,
                      Severity: Minor
                      Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.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 upgrade_110 has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function upgrade_110() {
                          global $wpdb;
                      
                          // Set user_nicename.
                          $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
                      Severity: Minor
                      Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 1 hr to fix

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

                        function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='') {
                            global $wp_rewrite;
                        
                            wp_check_mysql_version();
                            wp_cache_flush();
                        Severity: Minor
                        Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 1 hr to fix

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

                          function make_site_theme() {
                              // Name the theme after the blog.
                              $theme_name = __get_option('blogname');
                              $template = sanitize_title($theme_name);
                              $site_dir = WP_CONTENT_DIR . "/themes/$template";
                          Severity: Minor
                          Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.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 upgrade_210 has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function upgrade_210() {
                              global $wpdb, $wp_current_db_version;
                          
                              if ( $wp_current_db_version < 3506 ) {
                                  // Update status and type.
                          Severity: Minor
                          Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 1 hr to fix

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

                            function make_site_theme() {
                                // Name the theme after the blog.
                                $theme_name = __get_option('blogname');
                                $template = sanitize_title($theme_name);
                                $site_dir = WP_CONTENT_DIR . "/themes/$template";
                            Severity: Minor
                            Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 1 hr to fix

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

                              function __get_option($setting) {
                                  global $wpdb;
                              
                                  if ( $setting == 'home' && defined( 'WP_HOME' ) ) {
                                      return preg_replace( '|/+$|', '', constant( 'WP_HOME' ) );
                              Severity: Minor
                              Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.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 maybe_add_column has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                              Open

                              function maybe_add_column($table_name, $column_name, $create_ddl) {
                                  global $wpdb, $debug;
                                  foreach ($wpdb->get_col("DESC $table_name", 0) as $column ) {
                                      if ($debug) echo("checking $column == $column_name<br />");
                                      if ($column == $column_name) {
                              Severity: Minor
                              Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.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 wp_install has 5 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                              function wp_install($blog_title, $user_name, $user_email, $public, $deprecated='') {
                              Severity: Minor
                              Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 35 mins to fix

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

                                function upgrade_110() {
                                    global $wpdb;
                                
                                    // Set user_nicename.
                                    $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
                                Severity: Minor
                                Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.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 $option;
                                Severity: Major
                                Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                      return $template;
                                  Severity: Major
                                  Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return false;
                                    Severity: Major
                                    Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                              return 'subscriber';
                                      Severity: Major
                                      Found in Web.Admin/2014/wordpress/wp-admin/includes/upgrade.php - About 30 mins to fix

                                        There are no issues that match your filters.

                                        Category
                                        Status