CaffGeek/MBACNationals

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

Summary

Maintainability
D
2 days
Test Coverage

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

<?php
/**
 * WordPress User Page
 *
 * Handles authentication, registering, resetting passwords, forgot password,
Severity: Minor
Found in Web.Admin/2014/wordpress/wp-login.php - About 5 hrs to fix

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

    function login_header($title = 'Log In', $message = '', $wp_error = '') {
        global $error, $is_iphone, $interim_login;
    
        // Don't index any of these forms
        add_filter( 'pre_option_blog_public', create_function( '$a', 'return 0;' ) );
    Severity: Minor
    Found in Web.Admin/2014/wordpress/wp-login.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 login_header has 55 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function login_header($title = 'Log In', $message = '', $wp_error = '') {
        global $error, $is_iphone, $interim_login;
    
        // Don't index any of these forms
        add_filter( 'pre_option_blog_public', create_function( '$a', 'return 0;' ) );
    Severity: Major
    Found in Web.Admin/2014/wordpress/wp-login.php - About 2 hrs to fix

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

      function retrieve_password() {
          global $wpdb;
      
          $errors = new WP_Error();
      
      
      Severity: Minor
      Found in Web.Admin/2014/wordpress/wp-login.php - About 1 hr to fix

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

        function retrieve_password() {
            global $wpdb;
        
            $errors = new WP_Error();
        
        
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-login.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 register_new_user has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function register_new_user($user_login, $user_email) {
            $errors = new WP_Error();
        
            $user_login = sanitize_user( $user_login );
            $user_email = apply_filters( 'user_registration_email', $user_email );
        Severity: Minor
        Found in Web.Admin/2014/wordpress/wp-login.php - About 1 hr to fix

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

          function register_new_user($user_login, $user_email) {
              $errors = new WP_Error();
          
              $user_login = sanitize_user( $user_login );
              $user_email = apply_filters( 'user_registration_email', $user_email );
          Severity: Minor
          Found in Web.Admin/2014/wordpress/wp-login.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

          Consider simplifying this complex logical expression.
          Open

              if        ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] )
                  $errors->add('loggedout', __('You are now logged out.'), 'message');
              elseif    ( isset($_GET['registration']) && 'disabled' == $_GET['registration'] )
                  $errors->add('registerdisabled', __('User registration is currently not allowed.'));
              elseif    ( isset($_GET['checkemail']) && 'confirm' == $_GET['checkemail'] )
          Severity: Major
          Found in Web.Admin/2014/wordpress/wp-login.php - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                if ( !$secure_cookie && is_ssl() && force_ssl_login() && !force_ssl_admin() && ( 0 !== strpos($redirect_to, 'https') ) && ( 0 === strpos($redirect_to, 'http') ) )
                    $secure_cookie = false;
            Severity: Major
            Found in Web.Admin/2014/wordpress/wp-login.php - About 40 mins to fix

              Avoid too many return statements within this method.
              Open

                  return true;
              Severity: Major
              Found in Web.Admin/2014/wordpress/wp-login.php - About 30 mins to fix

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

                function reset_password($key, $login) {
                    global $wpdb;
                
                    $key = preg_replace('/[^a-z0-9]/i', '', $key);
                
                
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-login.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 ($user_email == '') {
                        $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.'));
                    } elseif ( !is_email( $user_email ) ) {
                        $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn&#8217;t correct.'));
                        $user_email = '';
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-login.php and 1 other location - About 50 mins to fix
                Web.Admin/2014/wordpress/wp-login.php on lines 250..256

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

                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 ( $user_login == '' )
                        $errors->add('empty_username', __('<strong>ERROR</strong>: Please enter a username.'));
                    elseif ( !validate_username( $user_login ) ) {
                        $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.'));
                        $user_login = '';
                Severity: Minor
                Found in Web.Admin/2014/wordpress/wp-login.php and 1 other location - About 50 mins to fix
                Web.Admin/2014/wordpress/wp-login.php on lines 259..265

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

                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