skyverge/wc-plugin-framework

View on GitHub
woocommerce/payment-gateway/class-sv-wc-payment-gateway.php

Summary

Maintainability
F
2 wks
Test Coverage

File class-sv-wc-payment-gateway.php has 1556 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WooCommerce Payment Gateway Framework
 *
 * This source file is subject to the GNU General Public License v3.0
Severity: Major
Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 4 days to fix

    SV_WC_Payment_Gateway has 170 functions (exceeds 20 allowed). Consider refactoring.
    Open

    #[\AllowDynamicProperties]
    abstract class SV_WC_Payment_Gateway extends \WC_Payment_Gateway {
    
    
        /** Sends through sale and request for funds to be charged to cardholder's credit card. */
    Severity: Major
    Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 3 days to fix

      Function add_transaction_data has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

          public function add_transaction_data( $order, $response = null ) {
      
              // transaction id if available
              if ( $response && $response->get_transaction_id() ) {
      
      
      Severity: Minor
      Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 6 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

      Consider simplifying this complex logical expression.
      Open

      if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_12_3\\SV_WC_Payment_Gateway' ) ) :
      
      
      /**
       * WooCommerce Payment Gateway Framework
      Severity: Critical
      Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 4 hrs to fix

        Function __construct has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __construct( $id, $plugin, $args ) {
        
                // first setup the gateway and payment type for this gateway
                $this->payment_type = isset( $args['payment_type'] ) ? $args['payment_type'] : self::PAYMENT_TYPE_CREDIT_CARD;
        
        
        Severity: Minor
        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 init_form_fields has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            public function init_form_fields() {
        
                // common top form fields
                $this->form_fields = array(
        
        
        Severity: Minor
        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 init_form_fields has 66 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function init_form_fields() {
        
                // common top form fields
                $this->form_fields = array(
        
        
        Severity: Major
        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 2 hrs to fix

          Method admin_options has 64 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function admin_options() {
          
                  parent::admin_options();
          
                  ?>
          Severity: Major
          Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 2 hrs to fix

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

                public function __construct( $id, $plugin, $args ) {
            
                    // first setup the gateway and payment type for this gateway
                    $this->payment_type = isset( $args['payment_type'] ) ? $args['payment_type'] : self::PAYMENT_TYPE_CREDIT_CARD;
            
            
            Severity: Major
            Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 2 hrs to fix

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

                  public function get_icon() {
              
                      $icon = '';
              
                      // specific icon
              Severity: Minor
              Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 add_transaction_data has 48 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function add_transaction_data( $order, $response = null ) {
              
                      // transaction id if available
                      if ( $response && $response->get_transaction_id() ) {
              
              
              Severity: Minor
              Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 1 hr to fix

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

                    public function add_debug_message( $message, ?string $type = 'message' ) : void {
                
                        // do nothing when debug mode is off or no message
                        if ( ! $message || ! is_string( $message ) || 'off' == $this->debug_off() ) {
                            return;
                Severity: Minor
                Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 process_refund has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function process_refund( $order_id, $amount = null, $reason = '' ) {
                
                        // add transaction-specific refund info (amount, reason, transaction IDs, etc)
                        $order = $this->get_order_for_refund( $order_id, $amount, $reason );
                
                
                Severity: Minor
                Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 load_shared_settings has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function load_shared_settings() {
                
                        // get any other sibling gateways
                        $other_gateway_ids = $this->get_ids_of_gateways_to_inherit_settings_from();
                
                
                Severity: Minor
                Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 add_shared_settings_form_fields has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function add_shared_settings_form_fields( $form_fields ) {
                
                        // get any sibling gateways
                        $other_gateway_ids                  = $this->get_ids_of_gateways_to_inherit_settings_from();
                        $configured_other_gateway_ids       = array();
                Severity: Minor
                Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 add_authorization_charge_form_fields has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function add_authorization_charge_form_fields( $form_fields ) {
                
                        assert( $this->supports_credit_card_authorization() && $this->supports_credit_card_charge() );
                
                        $form_fields['transaction_type'] = array(
                Severity: Minor
                Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 1 hr to fix

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

                      public function is_available() {
                  
                          // is enabled check
                          $is_available = parent::is_available();
                  
                  
                  Severity: Minor
                  Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 complete_payment has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function complete_payment( \WC_Order $order, SV_WC_Payment_Gateway_API_Response $response ) {
                  
                          if ( self::PAYMENT_TYPE_CREDIT_CARD == $response->get_payment_type() ) {
                              $order->add_order_note( $this->get_credit_card_transaction_approved_message( $order, $response ) );
                          } elseif ( self::PAYMENT_TYPE_ECHECK == $response->get_payment_type() ) {
                  Severity: Minor
                  Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 mark_order_as_held has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function mark_order_as_held( $order, $message, $response = null ) {
                  
                          /* translators: Placeholders: %1$s - payment gateway title, %2$s - message (probably reason for the transaction being held for review) */
                          $order_note = sprintf( esc_html__( '%1$s Transaction Held for Review (%2$s)', 'woocommerce-plugin-framework' ), $this->get_method_title(), $message );
                  
                  
                  Severity: Minor
                  Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 get_credit_card_transaction_approved_message has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function get_credit_card_transaction_approved_message( \WC_Order $order, $response ) {
                  
                          $last_four = ! empty( $order->payment->last_four ) ? $order->payment->last_four : substr( $order->payment->account_number, -4 );
                  
                          // use direct card type if set, or try to guess it from card number
                  Severity: Minor
                  Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 get_credit_card_transaction_approved_message has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function get_credit_card_transaction_approved_message( \WC_Order $order, $response ) {
                  
                          $last_four = ! empty( $order->payment->last_four ) ? $order->payment->last_four : substr( $order->payment->account_number, -4 );
                  
                          // use direct card type if set, or try to guess it from card number
                  Severity: Minor
                  Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 1 hr to fix

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

                        public function process_refund( $order_id, $amount = null, $reason = '' ) {
                    
                            // add transaction-specific refund info (amount, reason, transaction IDs, etc)
                            $order = $this->get_order_for_refund( $order_id, $amount, $reason );
                    
                    
                    Severity: Minor
                    Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 1 hr to fix

                      Method add_shared_settings_form_fields has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function add_shared_settings_form_fields( $form_fields ) {
                      
                              // get any sibling gateways
                              $other_gateway_ids                  = $this->get_ids_of_gateways_to_inherit_settings_from();
                              $configured_other_gateway_ids       = array();
                      Severity: Minor
                      Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 1 hr to fix

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

                            public function get_order( $order ) {
                        
                                if ( is_numeric( $order ) ) {
                                    $order = wc_get_order( $order );
                                }
                        Severity: Minor
                        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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

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

                            protected function enqueue_gateway_assets() {
                        
                                if ( ! $this->should_enqueue_gateway_assets() ) {
                                    return;
                                }
                        Severity: Minor
                        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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

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

                            public function admin_options() {
                        
                                parent::admin_options();
                        
                                ?>
                        Severity: Minor
                        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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

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

                            public function mark_order_as_failed( $order, $error_message, $response = null ) {
                        
                                /* translators: Placeholders: %1$s - payment gateway title, %2$s - error message; e.g. Order Note: [Payment method] Payment failed [error] */
                                $order_note = sprintf( esc_html__( '%1$s Payment Failed (%2$s)', 'woocommerce-plugin-framework' ), $this->get_method_title(), $error_message );
                        
                        
                        Severity: Minor
                        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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

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

                            protected function order_needs_shipping( $order ) {
                        
                                if ( get_option( 'woocommerce_calc_shipping' ) == 'no' ) {
                                    return false;
                                }
                        Severity: Minor
                        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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

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

                            public function add_support( $feature ) {
                        
                                if ( ! is_array( $feature ) ) {
                                    $feature = [ $feature ];
                                }
                        Severity: Minor
                        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 localize_script has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function localize_script( $handle, $params, $object_name = '' ) {
                        
                                // If the script isn't loaded, bail
                                if ( ! wp_script_is( $handle, 'enqueued' ) ) {
                                    return;
                        Severity: Minor
                        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 do_transaction_failed_result has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function do_transaction_failed_result( \WC_Order $order, SV_WC_Payment_Gateway_API_Response $response ) {
                        
                                $order_note = '';
                        
                                // build the order note with what data we have
                        Severity: Minor
                        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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_customer_id has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function get_customer_id( $user_id, $args = [] ) {
                        
                                $defaults = [
                                    'environment_id' => $this->get_environment(),
                                    'autocreate'     => true,
                        Severity: Minor
                        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 process_void has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function process_void( \WC_Order $order ) {
                        
                                // partial voids are not supported
                                if ( $order->refund->amount != $order->get_total() ) {
                                    return new \WP_Error( 'wc_' . $this->get_id() . '_void_error', esc_html__( 'Oops, you cannot partially void this order. Please use the full order amount.', 'woocommerce-plugin-framework' ), 500 );
                        Severity: Minor
                        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 remove_support has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function remove_support( $feature ) {
                        
                                if ( ! is_array( $feature ) ) {
                                    $feature = [ $feature ];
                                }
                        Severity: Minor
                        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 $error;
                        Severity: Major
                        Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 30 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                          return $error;
                          Severity: Major
                          Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php - About 30 mins to fix

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

                                public function is_pay_page_gateway() {
                            
                                    if ( is_checkout_pay_page() ) {
                            
                                        $order_id = $this->get_checkout_pay_page_order_id();
                            Severity: Minor
                            Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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

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

                                protected function add_customer_data( $order, $response = null ) {
                            
                                    $user_id = $order->get_user_id();
                            
                                    if ( $response && method_exists( $response, 'get_customer_id' ) && $response->get_customer_id() ) {
                            Severity: Minor
                            Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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

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

                                public function get_payment_method_image_url( $type ) {
                            
                                    $image_type = strtolower( $type );
                            
                                    if ( 'card' === $type ) {
                            Severity: Minor
                            Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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

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

                                protected function add_authorization_charge_form_fields( $form_fields ) {
                            
                                    assert( $this->supports_credit_card_authorization() && $this->supports_credit_card_charge() );
                            
                                    $form_fields['transaction_type'] = array(
                            Severity: Minor
                            Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.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 ( $response->get_status_code() && $response->get_status_message() ) {
                                        /* translators: Placeholders: %1$s - status code, %2$s - status message */
                                        $order_note = sprintf( esc_html__( 'Status code %1$s: %2$s', 'woocommerce-plugin-framework' ), $response->get_status_code(), $response->get_status_message() );
                                    } elseif ( $response->get_status_code() ) {
                                        /* translators: Placeholders: %s - status code */
                            Severity: Major
                            Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php and 1 other location - About 2 hrs to fix
                            woocommerce/payment-gateway/Handlers/Abstract_Payment_Handler.php on lines 151..160

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

                            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

                                protected function get_void_failed_wp_error( $error_code, $error_message ) {
                            
                                    if ( $error_code ) {
                                        $message = sprintf(
                                            /* translators: Placeholders: %1$s - payment gateway title, %2$s - error code, %3$s - error message. Void as in to void an order. */
                            Severity: Major
                            Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php and 1 other location - About 1 hr to fix
                            woocommerce/payment-gateway/class-sv-wc-payment-gateway.php on lines 2314..2334

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

                            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

                                protected function get_refund_failed_wp_error( $error_code, $error_message ) {
                            
                                    if ( $error_code ) {
                                        $message = sprintf(
                                            /* translators: Placeholders: %1$s - payment gateway title (such as Authorize.net, Braintree, etc), %2$s - error code, %3$s - error message */
                            Severity: Major
                            Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway.php and 1 other location - About 1 hr to fix
                            woocommerce/payment-gateway/class-sv-wc-payment-gateway.php on lines 2485..2505

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

                            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