WC_Post_Data
has 25 functions (exceeds 20 allowed). Consider refactoring. Open
class WC_Post_Data {
/**
* Editing term.
*
File class-wc-post-data.php
has 274 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Post Data
*
* Standardises certain post data on save.
Method delete_post
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function delete_post( $id ) {
if ( ! current_user_can( 'delete_posts' ) || ! $id ) {
return;
}
Function delete_post
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public static function delete_post( $id ) {
if ( ! current_user_can( 'delete_posts' ) || ! $id ) {
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
Function wp_insert_post_data
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function wp_insert_post_data( $data ) {
if ( 'shop_order' === $data['post_type'] && isset( $data['post_date'] ) ) {
$order_title = 'Order';
if ( $data['post_date'] ) {
$order_title .= ' – ' . date_i18n( 'F j, Y @ h:i A', strtotime( $data['post_date'] ) );
- 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 set_object_terms
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function set_object_terms( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) {
Method update_order_item_metadata
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function update_order_item_metadata( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
Method update_post_metadata
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function update_post_metadata( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
Method force_default_term
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function force_default_term( $object_id, $terms, $tt_ids, $taxonomy, $append ) {
Function before_delete_order
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public static function before_delete_order( $order_id ) {
if ( in_array( get_post_type( $order_id ), wc_get_order_types(), true ) ) {
// Clean up user.
$order = wc_get_order( $order_id );
- 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"