Method generate_product_data
has 126 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generate_product_data( $product = null ) {
if ( ! is_object( $product ) ) {
global $product;
}
File class-wc-structured-data.php
has 355 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Structured data's handler and generator using JSON-LD format.
*
* @package WooCommerce\Classes
Method generate_order_data
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generate_order_data( $order, $sent_to_admin = false, $plain_text = false ) {
if ( $plain_text || ! is_a( $order, 'WC_Order' ) ) {
return;
}
Function generate_product_data
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
public function generate_product_data( $product = null ) {
if ( ! is_object( $product ) ) {
global $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
Function generate_order_data
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function generate_order_data( $order, $sent_to_admin = false, $plain_text = false ) {
if ( $plain_text || ! is_a( $order, 'WC_Order' ) ) {
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 generate_breadcrumblist_data
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function generate_breadcrumblist_data( $breadcrumbs ) {
$crumbs = $breadcrumbs->get_breadcrumb();
if ( empty( $crumbs ) || ! is_array( $crumbs ) ) {
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 get_structured_data
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function get_structured_data( $types ) {
$data = array();
// Put together the values of same type of structured data.
foreach ( $this->get_data() as $value ) {
- 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"