Function prepare_attributes_for_export
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
protected function prepare_attributes_for_export( $product, &$row ) {
if ( $this->is_column_exporting( 'attributes' ) ) {
$attributes = $product->get_attributes();
$default_attributes = $product->get_default_attributes();
- 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
File class-wc-product-csv-exporter.php
has 369 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Handles product CSV export.
*
* @package WooCommerce\Export
WC_Product_CSV_Exporter
has 30 functions (exceeds 20 allowed). Consider refactoring. Open
class WC_Product_CSV_Exporter extends WC_CSV_Batch_Exporter {
/**
* Type of export used in filter names.
*
Function prepare_meta_for_export
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
protected function prepare_meta_for_export( $product, &$row ) {
if ( $this->enable_meta_export ) {
$meta_data = $product->get_meta_data();
if ( count( $meta_data ) ) {
- 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 prepare_attributes_for_export
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function prepare_attributes_for_export( $product, &$row ) {
if ( $this->is_column_exporting( 'attributes' ) ) {
$attributes = $product->get_attributes();
$default_attributes = $product->get_default_attributes();
Function prepare_data_to_export
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function prepare_data_to_export() {
$args = array(
'status' => array( 'private', 'publish', 'draft', 'future', 'pending' ),
'type' => $this->product_types_to_export,
'limit' => $this->get_limit(),
- 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_default_column_names
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_default_column_names() {
return apply_filters(
"woocommerce_product_export_{$this->export_type}_default_columns",
array(
'id' => __( 'ID', 'woocommerce' ),
Method prepare_data_to_export
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function prepare_data_to_export() {
$args = array(
'status' => array( 'private', 'publish', 'draft', 'future', 'pending' ),
'type' => $this->product_types_to_export,
'limit' => $this->get_limit(),
Function generate_row_data
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function generate_row_data( $product ) {
$columns = $this->get_column_names();
$row = array();
foreach ( $columns as $column_id => $column_name ) {
$column_id = strstr( $column_id, ':' ) ? current( explode( ':', $column_id ) ) : $column_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"
Further reading
Function prepare_downloads_for_export
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
protected function prepare_downloads_for_export( $product, &$row ) {
if ( $product->is_downloadable() && $this->is_column_exporting( 'downloads' ) ) {
$downloads = $product->get_downloads( 'edit' );
if ( $downloads ) {
- 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"