woothemes/woocommerce

View on GitHub
includes/import/abstract-wc-product-importer.php

Summary

Maintainability
F
4 days
Test Coverage

Function set_product_data has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
Open

    protected function set_product_data( &$product, $data ) {
        if ( isset( $data['raw_attributes'] ) ) {
            $attributes          = array();
            $default_attributes  = array();
            $existing_attributes = $product->get_attributes();
Severity: Minor
Found in includes/import/abstract-wc-product-importer.php - About 1 day to fix

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 abstract-wc-product-importer.php has 448 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Abstract Product importer
 *
 * @package  WooCommerce\Import
Severity: Minor
Found in includes/import/abstract-wc-product-importer.php - About 6 hrs to fix

    Function set_variation_data has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function set_variation_data( &$variation, $data ) {
            $parent = false;
    
            // Check if parent exist.
            if ( isset( $data['parent_id'] ) ) {
    Severity: Minor
    Found in includes/import/abstract-wc-product-importer.php - About 4 hrs to fix

    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_product_data has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function set_product_data( &$product, $data ) {
            if ( isset( $data['raw_attributes'] ) ) {
                $attributes          = array();
                $default_attributes  = array();
                $existing_attributes = $product->get_attributes();
    Severity: Major
    Found in includes/import/abstract-wc-product-importer.php - About 2 hrs to fix

      Method get_attachment_id_from_url has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function get_attachment_id_from_url( $url, $product_id ) {
              if ( empty( $url ) ) {
                  return 0;
              }
      
      
      Severity: Major
      Found in includes/import/abstract-wc-product-importer.php - About 2 hrs to fix

        WC_Product_Importer has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        abstract class WC_Product_Importer implements WC_Importer_Interface {
        
            /**
             * CSV file.
             *
        Severity: Minor
        Found in includes/import/abstract-wc-product-importer.php - About 2 hrs to fix

          Function process_item has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function process_item( $data ) {
                  try {
                      do_action( 'woocommerce_product_import_before_process_item', $data );
                      $data = apply_filters( 'woocommerce_product_import_process_item_data', $data );
          
          
          Severity: Minor
          Found in includes/import/abstract-wc-product-importer.php - About 2 hrs to fix

          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 process_item has 50 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function process_item( $data ) {
                  try {
                      do_action( 'woocommerce_product_import_before_process_item', $data );
                      $data = apply_filters( 'woocommerce_product_import_process_item_data', $data );
          
          
          Severity: Minor
          Found in includes/import/abstract-wc-product-importer.php - About 2 hrs to fix

            Method get_attribute_taxonomy_id has 44 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function get_attribute_taxonomy_id( $raw_name ) {
                    global $wpdb, $wc_product_attributes;
            
                    // These are exported as labels, so convert the label to a name if possible first.
                    $attribute_labels = wp_list_pluck( wc_get_attribute_taxonomies(), 'attribute_label', 'attribute_name' );
            Severity: Minor
            Found in includes/import/abstract-wc-product-importer.php - About 1 hr to fix

              Method set_variation_data has 43 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function set_variation_data( &$variation, $data ) {
                      $parent = false;
              
                      // Check if parent exist.
                      if ( isset( $data['parent_id'] ) ) {
              Severity: Minor
              Found in includes/import/abstract-wc-product-importer.php - About 1 hr to fix

                Function get_attachment_id_from_url has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function get_attachment_id_from_url( $url, $product_id ) {
                        if ( empty( $url ) ) {
                            return 0;
                        }
                
                
                Severity: Minor
                Found in includes/import/abstract-wc-product-importer.php - About 1 hr to fix

                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_product_object has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function get_product_object( $data ) {
                        $id = isset( $data['id'] ) ? absint( $data['id'] ) : 0;
                
                        // Type is the most important part here because we need to be using the correct class and methods.
                        if ( isset( $data['type'] ) ) {
                Severity: Minor
                Found in includes/import/abstract-wc-product-importer.php - About 1 hr to fix

                  Function get_product_object has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function get_product_object( $data ) {
                          $id = isset( $data['id'] ) ? absint( $data['id'] ) : 0;
                  
                          // Type is the most important part here because we need to be using the correct class and methods.
                          if ( isset( $data['type'] ) ) {
                  Severity: Minor
                  Found in includes/import/abstract-wc-product-importer.php - About 1 hr to fix

                  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_variation_parent_attributes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function get_variation_parent_attributes( $attributes, $parent ) {
                          $parent_attributes = $parent->get_attributes();
                          $require_save      = false;
                  
                          foreach ( $attributes as $attribute ) {
                  Severity: Minor
                  Found in includes/import/abstract-wc-product-importer.php - About 1 hr to fix

                  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

                  There are no issues that match your filters.

                  Category
                  Status