Function sync_attributes
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
public static function sync_attributes( $product, $children = false ) {
if ( ! is_a( $product, 'WC_Product' ) ) {
$product = wc_get_product( $product );
}
- 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
WC_Abstract_Legacy_Product
has 41 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class WC_Abstract_Legacy_Product extends WC_Data {
/**
* Magic __isset method for backwards compatibility. Legacy properties which could be accessed directly in the past.
*
File abstract-wc-legacy-product.php
has 345 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
Function __get
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function __get( $key ) {
if ( 'post_type' === $key ) {
return $this->post_type;
}
- 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
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __get( $key ) {
if ( 'post_type' === $key ) {
return $this->post_type;
}
Method __isset
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __isset( $key ) {
$valid = array(
'id',
'product_attributes',
'visibility',
Method sync_attributes
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function sync_attributes( $product, $children = false ) {
if ( ! is_a( $product, 'WC_Product' ) ) {
$product = wc_get_product( $product );
}
Function get_total_stock
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function get_total_stock() {
wc_deprecated_function( 'WC_Product::get_total_stock', '3.0', 'get_stock_quantity on each child. Beware of performance issues in doing so.' );
if ( sizeof( $this->get_children() ) > 0 ) {
$total_stock = max( 0, $this->get_stock_quantity() );
- 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 $value;