File class-wc-order-data-store-cpt.php
has 728 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WC_Order_Data_Store_CPT class file.
*
* @package WooCommerce\Classes
WC_Order_Data_Store_CPT
has 35 functions (exceeds 20 allowed). Consider refactoring. Open
class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implements WC_Object_Data_Store_Interface, WC_Order_Data_Store_Interface {
/**
* Data stored in meta keys, but not considered "meta" for an order.
*
Function get_wp_query_args
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
protected function get_wp_query_args( $query_vars ) {
// Map query vars to ones that get_wp_query_args or WP_Query recognize.
$key_mapping = array(
'customer_id' => 'customer_user',
- 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 update_post_meta
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function update_post_meta( &$order ) {
$updated_props = array();
$id = $order->get_id();
$meta_key_to_props = array(
'_order_key' => 'order_key',
Function update_post_meta
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
protected function update_post_meta( &$order ) {
$updated_props = array();
$id = $order->get_id();
$meta_key_to_props = array(
'_order_key' => 'order_key',
- 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_wp_query_args
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_wp_query_args( $query_vars ) {
// Map query vars to ones that get_wp_query_args or WP_Query recognize.
$key_mapping = array(
'customer_id' => 'customer_user',
Method prime_order_item_caches_for_orders
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function prime_order_item_caches_for_orders( $order_ids, $query_vars ) {
global $wpdb;
if ( isset( $query_vars['fields'] ) && 'all' !== $query_vars['fields'] ) {
$line_items = array(
'line_items',
Method prime_refund_caches_for_order
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function prime_refund_caches_for_order( $order_ids, $query_vars ) {
if ( ! isset( $query_vars['type'] ) || ! ( 'shop_order' === $query_vars['type'] ) ) {
return;
}
if ( isset( $query_vars['fields'] ) && 'all' !== $query_vars['fields'] ) {
Method read_order_data
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function read_order_data( &$order, $post_object ) {
parent::read_order_data( $order, $post_object );
$id = $order->get_id();
$date_completed = get_post_meta( $id, '_date_completed', true );
$date_paid = get_post_meta( $id, '_date_paid', true );
Function prime_refund_caches_for_order
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private function prime_refund_caches_for_order( $order_ids, $query_vars ) {
if ( ! isset( $query_vars['type'] ) || ! ( 'shop_order' === $query_vars['type'] ) ) {
return;
}
if ( isset( $query_vars['fields'] ) && 'all' !== $query_vars['fields'] ) {
- 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 prime_raw_meta_cache_for_orders
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function prime_raw_meta_cache_for_orders( $order_ids, $query_vars ) {
global $wpdb;
if ( isset( $query_vars['fields'] ) && 'all' !== $query_vars['fields'] ) {
if ( is_array( $query_vars['fields'] ) && ! in_array( 'meta_data', $query_vars['fields'] ) ) {
Method search_orders
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function search_orders( $term ) {
global $wpdb;
/**
* Searches on meta data can be slow - this lets you choose what fields to search.
Method get_orders_generate_customer_meta_query
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function get_orders_generate_customer_meta_query( $values, $relation = 'or' ) {
$meta_query = array(
'relation' => strtoupper( $relation ),
'customer_emails' => array(
'key' => '_billing_email',
Function prime_order_item_caches_for_orders
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function prime_order_item_caches_for_orders( $order_ids, $query_vars ) {
global $wpdb;
if ( isset( $query_vars['fields'] ) && 'all' !== $query_vars['fields'] ) {
$line_items = array(
'line_items',
- 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
Function get_orders_generate_customer_meta_query
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
private function get_orders_generate_customer_meta_query( $values, $relation = 'or' ) {
$meta_query = array(
'relation' => strtoupper( $relation ),
'customer_emails' => array(
'key' => '_billing_email',
- 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
Function prime_raw_meta_cache_for_orders
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
private function prime_raw_meta_cache_for_orders( $order_ids, $query_vars ) {
global $wpdb;
if ( isset( $query_vars['fields'] ) && 'all' !== $query_vars['fields'] ) {
if ( is_array( $query_vars['fields'] ) && ! in_array( 'meta_data', $query_vars['fields'] ) ) {
- 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
Function release_held_coupons
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function release_held_coupons( $order, $save = true ) {
$coupon_held_keys = $this->get_coupon_held_keys( $order );
if ( is_array( $coupon_held_keys ) ) {
foreach ( $coupon_held_keys as $coupon_id => $meta_key ) {
delete_post_meta( $coupon_id, $meta_key );
- 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
Avoid too many return
statements within this method. Open
return $order_items_collection;
Function query
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function query( $query_vars ) {
$args = $this->get_wp_query_args( $query_vars );
if ( ! empty( $args['errors'] ) ) {
$query = (object) array(
- 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"