WordPress/WordPress

View on GitHub
wp-signup.php

Summary

Maintainability
F
4 days
Test Coverage

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

<?php

/** Sets up the WordPress Environment. */
require __DIR__ . '/wp-load.php';

Severity: Major
Found in wp-signup.php - About 1 day to fix

    Method show_blog_form has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
        if ( ! is_wp_error( $errors ) ) {
            $errors = new WP_Error();
        }
    
    
    Severity: Major
    Found in wp-signup.php - About 3 hrs to fix

      Function show_blog_form has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      function show_blog_form( $blogname = '', $blog_title = '', $errors = '' ) {
          if ( ! is_wp_error( $errors ) ) {
              $errors = new WP_Error();
          }
      
      
      Severity: Minor
      Found in wp-signup.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 signup_another_blog has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function signup_another_blog( $blogname = '', $blog_title = '', $errors = '' ) {
          $current_user = wp_get_current_user();
      
          if ( ! is_wp_error( $errors ) ) {
              $errors = new WP_Error();
      Severity: Minor
      Found in wp-signup.php - About 2 hrs to fix

        Method signup_user has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function signup_user( $user_name = '', $user_email = '', $errors = '' ) {
            global $active_signup;
        
            if ( ! is_wp_error( $errors ) ) {
                $errors = new WP_Error();
        Severity: Minor
        Found in wp-signup.php - About 1 hr to fix

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

          function validate_another_blog_signup() {
              global $blogname, $blog_title, $errors, $domain, $path;
              $current_user = wp_get_current_user();
              if ( ! is_user_logged_in() ) {
                  die();
          Severity: Minor
          Found in wp-signup.php - About 1 hr to fix

            Method confirm_another_blog_signup has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array(), $blog_id = 0 ) {
            
                if ( $blog_id ) {
                    switch_to_blog( $blog_id );
                    $home_url  = home_url( '/' );
            Severity: Minor
            Found in wp-signup.php - About 1 hr to fix

              Method validate_blog_signup has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function validate_blog_signup() {
                  // Re-validate user info.
                  $user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
                  $user_name   = $user_result['user_name'];
                  $user_email  = $user_result['user_email'];
              Severity: Minor
              Found in wp-signup.php - About 1 hr to fix

                Method signup_blog has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '' ) {
                    if ( ! is_wp_error( $errors ) ) {
                        $errors = new WP_Error();
                    }
                
                
                Severity: Minor
                Found in wp-signup.php - About 1 hr to fix

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

                  function show_user_form( $user_name = '', $user_email = '', $errors = '' ) {
                      if ( ! is_wp_error( $errors ) ) {
                          $errors = new WP_Error();
                      }
                  
                  
                  Severity: Minor
                  Found in wp-signup.php - About 1 hr to fix

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

                    function wpmu_signup_stylesheet() {
                        ?>
                        <style type="text/css">
                            .mu_register { width: 90%; margin: 0 auto; }
                            .mu_register form { margin-top: 2em; }
                    Severity: Minor
                    Found in wp-signup.php - About 1 hr to fix

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

                      function validate_another_blog_signup() {
                          global $blogname, $blog_title, $errors, $domain, $path;
                          $current_user = wp_get_current_user();
                          if ( ! is_user_logged_in() ) {
                              die();
                      Severity: Minor
                      Found in wp-signup.php - About 55 mins to fix

                      Cognitive Complexity

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

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

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

                      Further reading

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

                      function confirm_another_blog_signup( $domain, $path, $blog_title, $user_name, $user_email = '', $meta = array(), $blog_id = 0 ) {
                      Severity: Major
                      Found in wp-signup.php - About 50 mins to fix

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

                        function validate_blog_signup() {
                            // Re-validate user info.
                            $user_result = wpmu_validate_user_signup( $_POST['user_name'], $_POST['user_email'] );
                            $user_name   = $user_result['user_name'];
                            $user_email  = $user_result['user_email'];
                        Severity: Minor
                        Found in wp-signup.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 confirm_blog_signup has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        function confirm_blog_signup( $domain, $path, $blog_title, $user_name = '', $user_email = '', $meta = array() ) {
                        Severity: Minor
                        Found in wp-signup.php - About 45 mins to fix

                          Consider simplifying this complex logical expression.
                          Open

                                      if ( is_user_logged_in() && ( 'all' === $active_signup || 'blog' === $active_signup ) ) {
                                          signup_another_blog( $newblogname );
                                      } elseif ( ! is_user_logged_in() && ( 'all' === $active_signup || 'user' === $active_signup ) ) {
                                          signup_user( $newblogname, $user_email );
                                      } elseif ( ! is_user_logged_in() && ( 'blog' === $active_signup ) ) {
                          Severity: Major
                          Found in wp-signup.php - About 40 mins to fix

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

                            function signup_blog( $user_name = '', $user_email = '', $blogname = '', $blog_title = '', $errors = '' ) {
                            Severity: Minor
                            Found in wp-signup.php - About 35 mins to fix

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

                                  if ( ! empty( $_POST['WPLANG'] ) ) {
                              
                                      $languages = signup_get_available_languages();
                              
                                      if ( in_array( $_POST['WPLANG'], $languages, true ) ) {
                              Severity: Minor
                              Found in wp-signup.php and 1 other location - About 30 mins to fix
                              wp-signup.php on lines 460..471

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 90.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

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

                                  if ( ! empty( $_POST['WPLANG'] ) ) {
                              
                                      $languages = signup_get_available_languages();
                              
                                      if ( in_array( $_POST['WPLANG'], $languages, true ) ) {
                              Severity: Minor
                              Found in wp-signup.php and 1 other location - About 30 mins to fix
                              wp-signup.php on lines 820..831

                              Duplicated Code

                              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                              Tuning

                              This issue has a mass of 90.

                              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                              Refactorings

                              Further Reading

                              There are no issues that match your filters.

                              Category
                              Status