woothemes/woocommerce

View on GitHub
includes/legacy/abstract-wc-legacy-product.php

Summary

Maintainability
F
3 days
Test Coverage

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 );
        }

Severity: Minor
Found in includes/legacy/abstract-wc-legacy-product.php - About 6 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

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.
     *
Severity: Minor
Found in includes/legacy/abstract-wc-legacy-product.php - About 5 hrs to fix

    File abstract-wc-legacy-product.php has 345 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    if ( ! defined( 'ABSPATH' ) ) {
        exit;
    }
    
    
    Severity: Minor
    Found in includes/legacy/abstract-wc-legacy-product.php - About 4 hrs to fix

      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;
              }
      Severity: Minor
      Found in includes/legacy/abstract-wc-legacy-product.php - About 3 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 __get has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function __get( $key ) {
      
              if ( 'post_type' === $key ) {
                  return $this->post_type;
              }
      Severity: Major
      Found in includes/legacy/abstract-wc-legacy-product.php - About 3 hrs to fix

        Method __isset has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function __isset( $key ) {
                $valid = array(
                    'id',
                    'product_attributes',
                    'visibility',
        Severity: Minor
        Found in includes/legacy/abstract-wc-legacy-product.php - About 1 hr to fix

          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 );
                  }
          
          
          Severity: Minor
          Found in includes/legacy/abstract-wc-legacy-product.php - About 1 hr to fix

            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() );
            
            
            Severity: Minor
            Found in includes/legacy/abstract-wc-legacy-product.php - About 35 mins 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

            Avoid too many return statements within this method.
            Open

                    return $value;
            Severity: Major
            Found in includes/legacy/abstract-wc-legacy-product.php - About 30 mins to fix

              There are no issues that match your filters.

              Category
              Status