skyverge/wc-plugin-framework

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

Summary

Maintainability
D
2 days
Test Coverage

File class-sv-wc-payment-gateway-payment-form.php has 413 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

    SV_WC_Payment_Gateway_Payment_Form has 36 functions (exceeds 20 allowed). Consider refactoring.
    Open

    #[\AllowDynamicProperties]
    class SV_WC_Payment_Gateway_Payment_Form extends Handlers\Script_Handler {
    
    
        /** @var \SV_WC_Payment_Gateway gateway for this payment form */

      Function get_tokens has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function get_tokens() {
      
              if ( ! empty( $this->tokens ) ) {
                  return $this->tokens;
              }

      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_fields has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function get_credit_card_fields() {
      
              $defaults = $this->get_gateway()->get_payment_method_defaults();
      
              $fields = [

        Method get_echeck_fields has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function get_echeck_fields() {
        
                $defaults = $this->get_gateway()->get_payment_method_defaults();
        
                $check_hint = sprintf( '<img title="%s" alt="%s" class="js-sv-wc-payment-gateway-echeck-form-check-hint" src="%s" width="16" height="16" />', esc_attr__( 'Where do I find this?', 'woocommerce-plugin-framework' ), esc_attr__( 'Where do I find this?', 'woocommerce-plugin-framework' ), esc_url( WC()->plugin_url() . '/assets/images/help.png' ) );

          Function tokenization_allowed has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function tokenization_allowed() {
          
                  // tokenization is allowed if tokenization is enabled on the gateway
                  $tokenization_allowed = $this->get_gateway()->supports_tokenization() && $this->get_gateway()->tokenization_enabled();
          
          

          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_saved_payment_method_title has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function get_saved_payment_method_title( $token ) {
          
                  $image_url = $token->get_image_url();
                  $last_four = $token->get_last_four();
                  $type      = $token->get_type_full();

          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_save_payment_method_checkbox_html has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function get_save_payment_method_checkbox_html() {
          
                  $html = '';
          
                  if ( $this->tokenization_allowed() || $this->tokenization_forced() ) {
          Severity: Minor
          Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.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_js_handler_args has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function get_js_handler_args() {
          
                  $args = [
                      'plugin_id'               => $this->get_gateway()->get_plugin()->get_id(),
                      'id'                      => $this->get_gateway()->get_id(),
          Severity: Minor
          Found in woocommerce/payment-gateway/class-sv-wc-payment-gateway-payment-form.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

          There are no issues that match your filters.

          Category
          Status