File class-wc-product-csv-importer.php
has 652 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* WooCommerce Product CSV importer
*
* @package WooCommerce\Import
Function expand_data
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
protected function expand_data( $data ) {
$data = apply_filters( 'woocommerce_product_importer_pre_expand_data', $data );
// Images field maps to image and gallery id fields.
if ( isset( $data['images'] ) ) {
- 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 expand_data
has 118 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function expand_data( $data ) {
$data = apply_filters( 'woocommerce_product_importer_pre_expand_data', $data );
// Images field maps to image and gallery id fields.
if ( isset( $data['images'] ) ) {
WC_Product_CSV_Importer
has 31 functions (exceeds 20 allowed). Consider refactoring. Open
class WC_Product_CSV_Importer extends WC_Product_Importer {
/**
* Tracks current row being parsed.
*
Function import
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
public function import() {
$this->start_time = time();
$index = 0;
$update_existing = $this->params['update_existing'];
$data = 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"
Further reading
Function parse_categories_field
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
public function parse_categories_field( $value ) {
if ( empty( $value ) ) {
return 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"
Further reading
Function read_file
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
protected function read_file() {
if ( ! WC_Product_CSV_Importer_Controller::is_file_valid_csv( $this->file ) ) {
wp_die( esc_html__( 'Invalid file type. The importer supports CSV and TXT file formats.', 'woocommerce' ) );
}
- 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 import
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function import() {
$this->start_time = time();
$index = 0;
$update_existing = $this->params['update_existing'];
$data = array(
Function set_parsed_data
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
protected function set_parsed_data() {
$parse_functions = $this->get_formatting_callback();
$mapped_keys = $this->get_mapped_keys();
$use_mb = function_exists( 'mb_convert_encoding' );
- 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_formatting_callback
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function get_formatting_callback() {
/**
* Columns not mentioned here will get parsed with 'wc_clean'.
* column_name => callback.
Method parse_relative_field
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse_relative_field( $value ) {
global $wpdb;
if ( empty( $value ) ) {
return '';
Function parse_relative_field
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function parse_relative_field( $value ) {
global $wpdb;
if ( empty( $value ) ) {
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_formatting_callback
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
protected function get_formatting_callback() {
/**
* Columns not mentioned here will get parsed with 'wc_clean'.
* column_name => callback.
- 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 read_file
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function read_file() {
if ( ! WC_Product_CSV_Importer_Controller::is_file_valid_csv( $this->file ) ) {
wp_die( esc_html__( 'Invalid file type. The importer supports CSV and TXT file formats.', 'woocommerce' ) );
}
Method parse_categories_field
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse_categories_field( $value ) {
if ( empty( $value ) ) {
return array();
}
Method set_parsed_data
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function set_parsed_data() {
$parse_functions = $this->get_formatting_callback();
$mapped_keys = $this->get_mapped_keys();
$use_mb = function_exists( 'mb_convert_encoding' );
Method parse_id_field
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function parse_id_field( $value ) {
global $wpdb;
$id = absint( $value );
Function parse_id_field
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function parse_id_field( $value ) {
global $wpdb;
$id = absint( $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"
Further reading
Function parse_tags_field
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function parse_tags_field( $value ) {
if ( empty( $value ) ) {
return 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"
Further reading
Function parse_tags_spaces_field
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function parse_tags_spaces_field( $value ) {
if ( empty( $value ) ) {
return 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"
Further reading
Avoid too many return
statements within this method. Open
return '';
Avoid too many return
statements within this method. Open
return '';
Avoid too many return
statements within this method. Open
return $id;
Avoid too many return
statements within this method. Open
return $id;