woothemes/woocommerce

View on GitHub
includes/shortcodes/class-wc-shortcode-my-account.php

Summary

Maintainability
D
1 day
Test Coverage

Function output has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    public static function output( $atts ) {
        global $wp;

        // Check cart class is loaded or abort.
        if ( is_null( WC()->cart ) ) {
Severity: Minor
Found in includes/shortcodes/class-wc-shortcode-my-account.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

Method output has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function output( $atts ) {
        global $wp;

        // Check cart class is loaded or abort.
        if ( is_null( WC()->cart ) ) {
Severity: Minor
Found in includes/shortcodes/class-wc-shortcode-my-account.php - About 1 hr to fix

    Method edit_address has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function edit_address( $load_address = 'billing' ) {
            $current_user = wp_get_current_user();
            $load_address = sanitize_key( $load_address );
            $country      = get_user_meta( get_current_user_id(), $load_address . '_country', true );
    
    
    Severity: Minor
    Found in includes/shortcodes/class-wc-shortcode-my-account.php - About 1 hr to fix

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

          public static function retrieve_password() {
              $login = isset( $_POST['user_login'] ) ? sanitize_user( wp_unslash( $_POST['user_login'] ) ) : ''; // WPCS: input var ok, CSRF ok.
      
              if ( empty( $login ) ) {
      
      
      Severity: Minor
      Found in includes/shortcodes/class-wc-shortcode-my-account.php - About 1 hr to fix

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

            public static function edit_address( $load_address = 'billing' ) {
                $current_user = wp_get_current_user();
                $load_address = sanitize_key( $load_address );
                $country      = get_user_meta( get_current_user_id(), $load_address . '_country', true );
        
        
        Severity: Minor
        Found in includes/shortcodes/class-wc-shortcode-my-account.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 retrieve_password has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function retrieve_password() {
                $login = isset( $_POST['user_login'] ) ? sanitize_user( wp_unslash( $_POST['user_login'] ) ) : ''; // WPCS: input var ok, CSRF ok.
        
                if ( empty( $login ) ) {
        
        
        Severity: Minor
        Found in includes/shortcodes/class-wc-shortcode-my-account.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 lost_password has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            public static function lost_password() {
                /**
                 * After sending the reset link, don't show the form again.
                 */
                if ( ! empty( $_GET['reset-link-sent'] ) ) { // WPCS: input var ok, CSRF ok.
        Severity: Minor
        Found in includes/shortcodes/class-wc-shortcode-my-account.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

        Avoid too many return statements within this method.
        Open

                    return false;
        Severity: Major
        Found in includes/shortcodes/class-wc-shortcode-my-account.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return false;
          Severity: Major
          Found in includes/shortcodes/class-wc-shortcode-my-account.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return true;
            Severity: Major
            Found in includes/shortcodes/class-wc-shortcode-my-account.php - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status