CaffGeek/MBACNationals

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

Summary

Maintainability
F
1 wk
Test Coverage

File ms-functions.php has 1013 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Multisite WordPress API
 *
 * @package WordPress
Severity: Major
Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 2 days to fix

    Function get_active_blog_for_user has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

    function get_active_blog_for_user( $user_id ) {
        global $wpdb;
        $blogs = get_blogs_of_user( $user_id );
        if ( empty( $blogs ) )
            return null;
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.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 wpmu_validate_user_signup has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

    function wpmu_validate_user_signup($user_name, $user_email) {
        global $wpdb;
    
        $errors = new WP_Error();
    
    
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.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 wpmu_validate_blog_signup has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
        global $wpdb, $domain;
    
        $current_site = get_current_site();
        $base = $current_site->path;
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.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 global_terms has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    function global_terms( $term_id, $deprecated = '' ) {
        global $wpdb;
        static $global_terms_recurse = null;
    
        if ( !global_terms_enabled() )
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.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 recurse_dirsize has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    function recurse_dirsize( $directory ) {
        $size = 0;
    
        $directory = untrailingslashit( $directory );
    
    
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.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 wpmu_validate_user_signup has 58 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function wpmu_validate_user_signup($user_name, $user_email) {
        global $wpdb;
    
        $errors = new WP_Error();
    
    
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 2 hrs to fix

      Method wpmu_validate_blog_signup has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
          global $wpdb, $domain;
      
          $current_site = get_current_site();
          $base = $current_site->path;
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 2 hrs to fix

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

        function is_email_address_unsafe( $user_email ) {
            $banned_names = get_site_option( 'banned_email_domains' );
            if ( $banned_names && ! is_array( $banned_names ) )
                $banned_names = explode( "\n", $banned_names );
        
        
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.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 remove_user_from_blog has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') {
            global $wpdb;
            switch_to_blog($blog_id);
            $user_id = (int) $user_id;
            /**
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.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 global_terms has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function global_terms( $term_id, $deprecated = '' ) {
            global $wpdb;
            static $global_terms_recurse = null;
        
            if ( !global_terms_enabled() )
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 1 hr to fix

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

          function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') {
              global $wpdb;
              switch_to_blog($blog_id);
              $user_id = (int) $user_id;
              /**
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 1 hr to fix

            Method get_active_blog_for_user has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function get_active_blog_for_user( $user_id ) {
                global $wpdb;
                $blogs = get_blogs_of_user( $user_id );
                if ( empty( $blogs ) )
                    return null;
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 1 hr to fix

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

              function wp_get_sites( $args = array() ) {
                  global $wpdb;
              
                  if ( wp_is_large_network() )
                      return array();
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.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 wpmu_activate_signup has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

              function wpmu_activate_signup($key) {
                  global $wpdb;
              
                  $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) );
              
              
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.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 wpmu_activate_signup has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function wpmu_activate_signup($key) {
                  global $wpdb;
              
                  $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) );
              
              
              Severity: Minor
              Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 1 hr to fix

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

                function wp_get_sites( $args = array() ) {
                    global $wpdb;
                
                    if ( wp_is_large_network() )
                        return array();
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 1 hr to fix

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

                  function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) {
                      $current_site = get_current_site();
                  
                      /**
                       * Filter whether to bypass the welcome email after site activation.
                  Severity: Minor
                  Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 1 hr to fix

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

                    function wpmu_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta = array() ) {
                        /**
                         * Filter whether to bypass the new site email notification.
                         *
                         * @since MU
                    Severity: Minor
                    Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 1 hr to fix

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

                      function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $site_id = 1 ) {
                          $defaults = array( 'public' => 0 );
                          $meta = wp_parse_args( $meta, $defaults );
                      
                          $domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) );
                      Severity: Minor
                      Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 1 hr to fix

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

                        function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $site_id = 1 ) {
                            $defaults = array( 'public' => 0 );
                            $meta = wp_parse_args( $meta, $defaults );
                        
                            $domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) );
                        Severity: Minor
                        Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.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 wpmu_signup_blog_notification has 7 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        function wpmu_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta = array() ) {
                        Severity: Major
                        Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 50 mins to fix

                          Method wpmu_signup_blog has 6 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          function wpmu_signup_blog( $domain, $path, $title, $user, $user_email, $meta = array() )  {
                          Severity: Minor
                          Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 45 mins to fix

                            Method wpmu_create_blog has 6 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            function wpmu_create_blog( $domain, $path, $title, $user_id, $meta = array(), $site_id = 1 ) {
                            Severity: Minor
                            Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if ($handlesize > 0)
                                                      $size += $handlesize;
                              Severity: Major
                              Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 45 mins to fix

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

                                function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = array() ) {
                                Severity: Minor
                                Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 35 mins to fix

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

                                  function check_upload_mimes( $mimes ) {
                                      $site_exts = explode( ' ', get_site_option( 'upload_filetypes' ) );
                                      foreach ( $site_exts as $ext ) {
                                          foreach ( $mimes as $ext_pattern => $mime ) {
                                              if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false )
                                  Severity: Minor
                                  Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.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_most_recent_post_of_user has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  function get_most_recent_post_of_user( $user_id ) {
                                      global $wpdb;
                                  
                                      $user_blogs = get_blogs_of_user( (int) $user_id );
                                      $most_recent_post = array();
                                  Severity: Minor
                                  Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.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 $blog_id;
                                  Severity: Major
                                  Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup);
                                    Severity: Major
                                    Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                              return array( 'user_id' => $user_id, 'password' => $password, 'meta' => $meta );
                                      Severity: Major
                                      Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                            return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta);
                                        Severity: Major
                                        Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                  return $primary;
                                          Severity: Major
                                          Found in Web.Admin/2014/wordpress/wp-includes/ms-functions.php - About 30 mins to fix

                                            There are no issues that match your filters.

                                            Category
                                            Status