woothemes/woocommerce

View on GitHub
includes/gateways/bacs/class-wc-gateway-bacs.php

Summary

Maintainability
D
1 day
Test Coverage

File class-wc-gateway-bacs.php has 300 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Class WC_Gateway_BACS file.
 *
 * @package WooCommerce\Gateways
Severity: Minor
Found in includes/gateways/bacs/class-wc-gateway-bacs.php - About 3 hrs to fix

    Method generate_account_details_html has 68 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function generate_account_details_html() {
    
            ob_start();
    
            $country = WC()->countries->get_base_country();
    Severity: Major
    Found in includes/gateways/bacs/class-wc-gateway-bacs.php - About 2 hrs to fix

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

          private function bank_details( $order_id = '' ) {
      
              if ( empty( $this->account_details ) ) {
                  return;
              }
      Severity: Major
      Found in includes/gateways/bacs/class-wc-gateway-bacs.php - About 2 hrs to fix

        Function bank_details has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            private function bank_details( $order_id = '' ) {
        
                if ( empty( $this->account_details ) ) {
                    return;
                }
        Severity: Minor
        Found in includes/gateways/bacs/class-wc-gateway-bacs.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 get_country_locale has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function get_country_locale() {
        
                if ( empty( $this->locale ) ) {
        
                    // Locale information to be used - only those that are not 'Sort Code'.
        Severity: Minor
        Found in includes/gateways/bacs/class-wc-gateway-bacs.php - About 1 hr to fix

          Method init_form_fields has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function init_form_fields() {
          
                  $this->form_fields = array(
                      'enabled'         => array(
                          'title'   => __( 'Enable/Disable', 'woocommerce' ),
          Severity: Minor
          Found in includes/gateways/bacs/class-wc-gateway-bacs.php - About 1 hr to fix

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

                public function __construct() {
            
                    $this->id                 = 'bacs';
                    $this->icon               = apply_filters( 'woocommerce_bacs_icon', '' );
                    $this->has_fields         = false;
            Severity: Minor
            Found in includes/gateways/bacs/class-wc-gateway-bacs.php - About 1 hr to fix

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

                  public function save_account_details() {
              
                      $accounts = array();
              
                      // phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verification already handled in WC_Admin_Settings::save()
              Severity: Minor
              Found in includes/gateways/bacs/class-wc-gateway-bacs.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( $_POST['bacs_account_name'] ) && isset( $_POST['bacs_account_number'] ) && isset( $_POST['bacs_bank_name'] )
                           && isset( $_POST['bacs_sort_code'] ) && isset( $_POST['bacs_iban'] ) && isset( $_POST['bacs_bic'] ) ) {
              
                          $account_names   = wc_clean( wp_unslash( $_POST['bacs_account_name'] ) );
                          $account_numbers = wc_clean( wp_unslash( $_POST['bacs_account_number'] ) );
              Severity: Major
              Found in includes/gateways/bacs/class-wc-gateway-bacs.php - About 40 mins to fix

                There are no issues that match your filters.

                Category
                Status