includes/gateways/bacs/class-wc-gateway-bacs.php
File class-wc-gateway-bacs.php
has 300 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
<?php
/**
* Class WC_Gateway_BACS file.
*
* @package WooCommerce\Gateways
Method generate_account_details_html
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function generate_account_details_html() {
ob_start();
$country = WC()->countries->get_base_country();
Method bank_details
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
private function bank_details( $order_id = '' ) {
if ( empty( $this->account_details ) ) {
return;
}
Function bank_details
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
Open
private function bank_details( $order_id = '' ) {
if ( empty( $this->account_details ) ) {
return;
}
- Read upRead up
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
Open
public function get_country_locale() {
if ( empty( $this->locale ) ) {
// Locale information to be used - only those that are not 'Sort Code'.
Method init_form_fields
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce' ),
Method __construct
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function __construct() {
$this->id = 'bacs';
$this->icon = apply_filters( 'woocommerce_bacs_icon', '' );
$this->has_fields = false;
Function save_account_details
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
public function save_account_details() {
$accounts = array();
// phpcs:disable WordPress.Security.NonceVerification.Missing -- Nonce verification already handled in WC_Admin_Settings::save()
- Read upRead up
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
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'] ) );