CaffGeek/MBACNationals

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

Summary

Maintainability
F
6 days
Test Coverage

Function get_blog_details has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

function get_blog_details( $fields = null, $get_all = true ) {
    global $wpdb;

    if ( is_array($fields ) ) {
        if ( isset($fields['blog_id']) ) {
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.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

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

<?php

/**
 * Site/blog functions that work with the blogs table and related data.
 *
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.php - About 6 hrs to fix

    Method get_blog_details has 101 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function get_blog_details( $fields = null, $get_all = true ) {
        global $wpdb;
    
        if ( is_array($fields ) ) {
            if ( isset($fields['blog_id']) ) {
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.php - About 4 hrs to fix

      Function update_blog_details has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

      function update_blog_details( $blog_id, $details = array() ) {
          global $wpdb;
      
          if ( empty($details) )
              return false;
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.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 update_blog_status has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
          global $wpdb;
      
          if ( null !== $deprecated  )
              _deprecated_argument( __FUNCTION__, '3.1' );
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.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 update_blog_details has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function update_blog_details( $blog_id, $details = array() ) {
          global $wpdb;
      
          if ( empty($details) )
              return false;
      Severity: Major
      Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.php - About 2 hrs to fix

        Function restore_current_blog has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        function restore_current_blog() {
            global $wpdb, $wp_roles;
        
            if ( empty( $GLOBALS['_wp_switched_stack'] ) )
                return false;
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.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 switch_to_blog has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        function switch_to_blog( $new_blog, $deprecated = null ) {
            global $wpdb, $wp_roles;
        
            if ( empty( $new_blog ) )
                $new_blog = $GLOBALS['blog_id'];
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.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 switch_to_blog has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function switch_to_blog( $new_blog, $deprecated = null ) {
            global $wpdb, $wp_roles;
        
            if ( empty( $new_blog ) )
                $new_blog = $GLOBALS['blog_id'];
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.php - About 1 hr to fix

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

          function restore_current_blog() {
              global $wpdb, $wp_roles;
          
              if ( empty( $GLOBALS['_wp_switched_stack'] ) )
                  return false;
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.php - About 1 hr to fix

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

            function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
                global $wpdb;
            
                if ( null !== $deprecated  )
                    _deprecated_argument( __FUNCTION__, '3.1' );
            Severity: Minor
            Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.php - About 1 hr to fix

              Avoid too many return statements within this method.
              Open

                          return $details;
              Severity: Major
              Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.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-includes/ms-blogs.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-includes/ms-blogs.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-includes/ms-blogs.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

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

                        Avoid too many return statements within this method.
                        Open

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

                          Avoid too many return statements within this method.
                          Open

                              return $details;
                          Severity: Major
                          Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.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-includes/ms-blogs.php - About 30 mins to fix

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

                              function get_blogaddress_by_name( $blogname ) {
                                  if ( is_subdomain_install() ) {
                                      if ( $blogname == 'main' )
                                          $blogname = 'www';
                                      $url = rtrim( network_home_url(), '/' );
                              Severity: Minor
                              Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.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

                                  if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
                                      wp_cache_switch_to_blog( $new_blog );
                                  } else {
                                      global $wp_object_cache;
                              
                              
                              Severity: Major
                              Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.php and 1 other location - About 4 hrs to fix
                              Web.Admin/2014/wordpress/wp-includes/ms-blogs.php on lines 669..688

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

                              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

                                  if ( function_exists( 'wp_cache_switch_to_blog' ) ) {
                                      wp_cache_switch_to_blog( $blog );
                                  } else {
                                      global $wp_object_cache;
                              
                              
                              Severity: Major
                              Found in Web.Admin/2014/wordpress/wp-includes/ms-blogs.php and 1 other location - About 4 hrs to fix
                              Web.Admin/2014/wordpress/wp-includes/ms-blogs.php on lines 606..625

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

                              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