woothemes/woocommerce

View on GitHub
includes/legacy/api/v3/class-wc-api-orders.php

Summary

Maintainability
F
2 mos
Test Coverage

File class-wc-api-orders.php has 1114 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WooCommerce API Orders Class
 *
 * Handles requests to the /orders endpoint
Severity: Major
Found in includes/legacy/api/v3/class-wc-api-orders.php - About 2 days to fix

    Method get_order has 148 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function get_order( $id, $fields = null, $filter = array() ) {
    
            // Ensure order ID is valid & user has permission to read.
            $id = $this->validate_request( $id, $this->post_type, 'read' );
    
    
    Severity: Major
    Found in includes/legacy/api/v3/class-wc-api-orders.php - About 5 hrs to fix

      Function edit_order has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

          public function edit_order( $id, $data ) {
              try {
                  if ( ! isset( $data['order'] ) ) {
                      throw new WC_API_Exception( 'woocommerce_api_missing_order_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order' ), 400 );
                  }
      Severity: Minor
      Found in includes/legacy/api/v3/class-wc-api-orders.php - About 5 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

      Function set_line_item has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function set_line_item( $order, $item, $action ) {
              $creating  = ( 'create' === $action );
      
              // product is always required
              if ( ! isset( $item['product_id'] ) && ! isset( $item['sku'] ) ) {
      Severity: Minor
      Found in includes/legacy/api/v3/class-wc-api-orders.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

      WC_API_Orders has 32 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class WC_API_Orders extends WC_API_Resource {
      
          /** @var string $base the route base */
          protected $base = '/orders';
      
      
      Severity: Minor
      Found in includes/legacy/api/v3/class-wc-api-orders.php - About 4 hrs to fix

        Function create_order has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

            public function create_order( $data ) {
                global $wpdb;
        
                try {
                    if ( ! isset( $data['order'] ) ) {
        Severity: Minor
        Found in includes/legacy/api/v3/class-wc-api-orders.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

        Function get_order has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            public function get_order( $id, $fields = null, $filter = array() ) {
        
                // Ensure order ID is valid & user has permission to read.
                $id = $this->validate_request( $id, $this->post_type, 'read' );
        
        
        Severity: Minor
        Found in includes/legacy/api/v3/class-wc-api-orders.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

        Function set_fee has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function set_fee( $order, $fee, $action ) {
        
                if ( 'create' === $action ) {
        
                    // fee title is required
        Severity: Minor
        Found in includes/legacy/api/v3/class-wc-api-orders.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 edit_order has 86 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function edit_order( $id, $data ) {
                try {
                    if ( ! isset( $data['order'] ) ) {
                        throw new WC_API_Exception( 'woocommerce_api_missing_order_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order' ), 400 );
                    }
        Severity: Major
        Found in includes/legacy/api/v3/class-wc-api-orders.php - About 3 hrs to fix

          Method set_line_item has 73 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function set_line_item( $order, $item, $action ) {
                  $creating  = ( 'create' === $action );
          
                  // product is always required
                  if ( ! isset( $item['product_id'] ) && ! isset( $item['sku'] ) ) {
          Severity: Major
          Found in includes/legacy/api/v3/class-wc-api-orders.php - About 2 hrs to fix

            Method create_order has 72 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function create_order( $data ) {
                    global $wpdb;
            
                    try {
                        if ( ! isset( $data['order'] ) ) {
            Severity: Major
            Found in includes/legacy/api/v3/class-wc-api-orders.php - About 2 hrs to fix

              Function get_variation_id has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function get_variation_id( $product, $variations = array() ) {
                      $variation_id = null;
                      $variations_normalized = array();
              
                      if ( $product->is_type( 'variable' ) && $product->has_child() ) {
              Severity: Minor
              Found in includes/legacy/api/v3/class-wc-api-orders.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

              Function set_order_addresses has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function set_order_addresses( $order, $data ) {
              
                      $address_fields = array(
                          'first_name',
                          'last_name',
              Severity: Minor
              Found in includes/legacy/api/v3/class-wc-api-orders.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

              Function create_order_refund has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function create_order_refund( $order_id, $data, $api_refund = true ) {
                      try {
                          if ( ! isset( $data['order_refund'] ) ) {
                              throw new WC_API_Exception( 'woocommerce_api_missing_order_refund_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'order_refund' ), 400 );
                          }
              Severity: Minor
              Found in includes/legacy/api/v3/class-wc-api-orders.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

              Function bulk has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function bulk( $data ) {
              
                      try {
                          if ( ! isset( $data['orders'] ) ) {
                              throw new WC_API_Exception( 'woocommerce_api_missing_orders_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'orders' ), 400 );
              Severity: Minor
              Found in includes/legacy/api/v3/class-wc-api-orders.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 get_order_refund has 51 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function get_order_refund( $order_id, $id, $fields = null, $filter = array() ) {
                      try {
                          // Validate order ID
                          $order_id = $this->validate_request( $order_id, $this->post_type, 'read' );
              
              
              Severity: Major
              Found in includes/legacy/api/v3/class-wc-api-orders.php - About 2 hrs to fix

                Method create_order_refund has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function create_order_refund( $order_id, $data, $api_refund = true ) {
                        try {
                            if ( ! isset( $data['order_refund'] ) ) {
                                throw new WC_API_Exception( 'woocommerce_api_missing_order_refund_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'order_refund' ), 400 );
                            }
                Severity: Minor
                Found in includes/legacy/api/v3/class-wc-api-orders.php - About 1 hr to fix

                  Method register_routes has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function register_routes( $routes ) {
                  
                          # GET|POST /orders
                          $routes[ $this->base ] = array(
                              array( array( $this, 'get_orders' ),     WC_API_Server::READABLE ),
                  Severity: Minor
                  Found in includes/legacy/api/v3/class-wc-api-orders.php - About 1 hr to fix

                    Function set_shipping has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function set_shipping( $order, $shipping, $action ) {
                    
                            // total must be a positive float
                            if ( isset( $shipping['total'] ) && floatval( $shipping['total'] ) < 0 ) {
                                throw new WC_API_Exception( 'woocommerce_invalid_shipping_total', __( 'Shipping total must be a positive amount.', 'woocommerce' ), 400 );
                    Severity: Minor
                    Found in includes/legacy/api/v3/class-wc-api-orders.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 bulk has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function bulk( $data ) {
                    
                            try {
                                if ( ! isset( $data['orders'] ) ) {
                                    throw new WC_API_Exception( 'woocommerce_api_missing_orders_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'orders' ), 400 );
                    Severity: Minor
                    Found in includes/legacy/api/v3/class-wc-api-orders.php - About 1 hr to fix

                      Method set_fee has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function set_fee( $order, $fee, $action ) {
                      
                              if ( 'create' === $action ) {
                      
                                  // fee title is required
                      Severity: Minor
                      Found in includes/legacy/api/v3/class-wc-api-orders.php - About 1 hr to fix

                        Method set_order_addresses has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function set_order_addresses( $order, $data ) {
                        
                                $address_fields = array(
                                    'first_name',
                                    'last_name',
                        Severity: Minor
                        Found in includes/legacy/api/v3/class-wc-api-orders.php - About 1 hr to fix

                          Method edit_order_note has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function edit_order_note( $order_id, $id, $data ) {
                                  try {
                                      if ( ! isset( $data['order_note'] ) ) {
                                          throw new WC_API_Exception( 'woocommerce_api_missing_order_note_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order_note' ), 400 );
                                      }
                          Severity: Minor
                          Found in includes/legacy/api/v3/class-wc-api-orders.php - About 1 hr to fix

                            Method edit_order_refund has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                                public function edit_order_refund( $order_id, $id, $data ) {
                                    try {
                                        if ( ! isset( $data['order_refund'] ) ) {
                                            throw new WC_API_Exception( 'woocommerce_api_missing_order_refund_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order_refund' ), 400 );
                                        }
                            Severity: Minor
                            Found in includes/legacy/api/v3/class-wc-api-orders.php - About 1 hr to fix

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

                                  public function edit_order_refund( $order_id, $id, $data ) {
                                      try {
                                          if ( ! isset( $data['order_refund'] ) ) {
                                              throw new WC_API_Exception( 'woocommerce_api_missing_order_refund_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order_refund' ), 400 );
                                          }
                              Severity: Minor
                              Found in includes/legacy/api/v3/class-wc-api-orders.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 set_coupon has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                              Open

                                  protected function set_coupon( $order, $coupon, $action ) {
                              
                                      // coupon amount must be positive float
                                      if ( isset( $coupon['amount'] ) && floatval( $coupon['amount'] ) < 0 ) {
                                          throw new WC_API_Exception( 'woocommerce_invalid_coupon_total', __( 'Coupon discount total must be a positive amount.', 'woocommerce' ), 400 );
                              Severity: Minor
                              Found in includes/legacy/api/v3/class-wc-api-orders.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 create_order_note has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function create_order_note( $order_id, $data ) {
                                      try {
                                          if ( ! isset( $data['order_note'] ) ) {
                                              throw new WC_API_Exception( 'woocommerce_api_missing_order_note_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'order_note' ), 400 );
                                          }
                              Severity: Minor
                              Found in includes/legacy/api/v3/class-wc-api-orders.php - About 1 hr to fix

                                Method set_coupon has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    protected function set_coupon( $order, $coupon, $action ) {
                                
                                        // coupon amount must be positive float
                                        if ( isset( $coupon['amount'] ) && floatval( $coupon['amount'] ) < 0 ) {
                                            throw new WC_API_Exception( 'woocommerce_invalid_coupon_total', __( 'Coupon discount total must be a positive amount.', 'woocommerce' ), 400 );
                                Severity: Minor
                                Found in includes/legacy/api/v3/class-wc-api-orders.php - About 1 hr to fix

                                  Method set_shipping has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                      protected function set_shipping( $order, $shipping, $action ) {
                                  
                                          // total must be a positive float
                                          if ( isset( $shipping['total'] ) && floatval( $shipping['total'] ) < 0 ) {
                                              throw new WC_API_Exception( 'woocommerce_invalid_shipping_total', __( 'Shipping total must be a positive amount.', 'woocommerce' ), 400 );
                                  Severity: Minor
                                  Found in includes/legacy/api/v3/class-wc-api-orders.php - About 1 hr to fix

                                    Function get_orders_count has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function get_orders_count( $status = null, $filter = array() ) {
                                    
                                            try {
                                                if ( ! current_user_can( 'read_private_shop_orders' ) ) {
                                                    throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_orders_count', __( 'You do not have permission to read the orders count', 'woocommerce' ), 401 );
                                    Severity: Minor
                                    Found in includes/legacy/api/v3/class-wc-api-orders.php - About 55 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

                                    Function edit_order_note has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function edit_order_note( $order_id, $id, $data ) {
                                            try {
                                                if ( ! isset( $data['order_note'] ) ) {
                                                    throw new WC_API_Exception( 'woocommerce_api_missing_order_note_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order_note' ), 400 );
                                                }
                                    Severity: Minor
                                    Found in includes/legacy/api/v3/class-wc-api-orders.php - About 55 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

                                    Function get_order_refund has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function get_order_refund( $order_id, $id, $fields = null, $filter = array() ) {
                                            try {
                                                // Validate order ID
                                                $order_id = $this->validate_request( $order_id, $this->post_type, 'read' );
                                    
                                    
                                    Severity: Minor
                                    Found in includes/legacy/api/v3/class-wc-api-orders.php - About 45 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

                                    Function create_order_note has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        public function create_order_note( $order_id, $data ) {
                                            try {
                                                if ( ! isset( $data['order_note'] ) ) {
                                                    throw new WC_API_Exception( 'woocommerce_api_missing_order_note_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'order_note' ), 400 );
                                                }
                                    Severity: Minor
                                    Found in includes/legacy/api/v3/class-wc-api-orders.php - About 45 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 new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
                                    Severity: Major
                                    Found in includes/legacy/api/v3/class-wc-api-orders.php - About 30 mins to fix

                                      Function delete_order_note has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          public function delete_order_note( $order_id, $id ) {
                                              try {
                                                  $order_id = $this->validate_request( $order_id, $this->post_type, 'delete' );
                                      
                                                  if ( is_wp_error( $order_id ) ) {
                                      Severity: Minor
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php - About 25 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

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function edit_order( $id, $data ) {
                                              try {
                                                  if ( ! isset( $data['order'] ) ) {
                                                      throw new WC_API_Exception( 'woocommerce_api_missing_order_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order' ), 400 );
                                                  }
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 6 days to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 501..638

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 1078.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          protected function set_line_item( $order, $item, $action ) {
                                              $creating  = ( 'create' === $action );
                                      
                                              // product is always required
                                              if ( ! isset( $item['product_id'] ) && ! isset( $item['sku'] ) ) {
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 4 days to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 860..956

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 841.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function get_order_refund( $order_id, $id, $fields = null, $filter = array() ) {
                                              try {
                                                  // Validate order ID
                                                  $order_id = $this->validate_request( $order_id, $this->post_type, 'read' );
                                      
                                      
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 3 days to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1500..1565

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 664.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function create_order_refund( $order_id, $data, $api_refund = true ) {
                                              try {
                                                  if ( ! isset( $data['order_refund'] ) ) {
                                                      throw new WC_API_Exception( 'woocommerce_api_missing_order_refund_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'order_refund' ), 400 );
                                                  }
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 3 days to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1576..1644

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 618.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function register_routes( $routes ) {
                                      
                                              # GET|POST /orders
                                              $routes[ $this->base ] = array(
                                                  array( array( $this, 'get_orders' ),     WC_API_Server::READABLE ),
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 3 days to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 37..94

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 578.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          protected function set_fee( $order, $fee, $action ) {
                                      
                                              if ( 'create' === $action ) {
                                      
                                                  // fee title is required
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 2 days to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1077..1137

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 507.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function edit_order_note( $order_id, $id, $data ) {
                                              try {
                                                  if ( ! isset( $data['order_note'] ) ) {
                                                      throw new WC_API_Exception( 'woocommerce_api_missing_order_note_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order_note' ), 400 );
                                                  }
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 2 days to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1341..1404

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 497.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function edit_order_refund( $order_id, $id, $data ) {
                                              try {
                                                  if ( ! isset( $data['order_refund'] ) ) {
                                                      throw new WC_API_Exception( 'woocommerce_api_missing_order_refund_data', sprintf( __( 'No %1$s data specified to edit %1$s', 'woocommerce' ), 'order_refund' ), 400 );
                                                  }
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 2 days to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1655..1713

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 491.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function bulk( $data ) {
                                      
                                              try {
                                                  if ( ! isset( $data['orders'] ) ) {
                                                      throw new WC_API_Exception( 'woocommerce_api_missing_orders_data', sprintf( __( 'No %1$s data specified to create/edit %1$s', 'woocommerce' ), 'orders' ), 400 );
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 2 days to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1771..1829

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 467.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function create_order_note( $order_id, $data ) {
                                              try {
                                                  if ( ! isset( $data['order_note'] ) ) {
                                                      throw new WC_API_Exception( 'woocommerce_api_missing_order_note_data', sprintf( __( 'No %1$s data specified to create %1$s', 'woocommerce' ), 'order_note' ), 400 );
                                                  }
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 2 days to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1282..1330

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 426.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          protected function set_shipping( $order, $shipping, $action ) {
                                      
                                              // total must be a positive float
                                              if ( isset( $shipping['total'] ) && floatval( $shipping['total'] ) < 0 ) {
                                                  throw new WC_API_Exception( 'woocommerce_invalid_shipping_total', __( 'Shipping total must be a positive amount.', 'woocommerce' ), 400 );
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 1 day to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1025..1066

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 378.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          protected function set_order_addresses( $order, $data ) {
                                      
                                              $address_fields = array(
                                                  'first_name',
                                                  'last_name',
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 1 day to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 702..757

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 325.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          protected function set_coupon( $order, $coupon, $action ) {
                                      
                                              // coupon amount must be positive float
                                              if ( isset( $coupon['amount'] ) && floatval( $coupon['amount'] ) < 0 ) {
                                                  throw new WC_API_Exception( 'woocommerce_invalid_coupon_total', __( 'Coupon discount total must be a positive amount.', 'woocommerce' ), 400 );
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 1 day to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1148..1188

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 317.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function delete_order_note( $order_id, $id ) {
                                              try {
                                                  $order_id = $this->validate_request( $order_id, $this->post_type, 'delete' );
                                      
                                                  if ( is_wp_error( $order_id ) ) {
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 1 day to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1414..1454

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 314.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function get_order_note( $order_id, $id, $fields = null ) {
                                              try {
                                                  // Validate order ID
                                                  $order_id = $this->validate_request( $order_id, $this->post_type, 'read' );
                                      
                                      
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 1 day to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1240..1272

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 293.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function delete_order_refund( $order_id, $id ) {
                                              try {
                                                  $order_id = $this->validate_request( $order_id, $this->post_type, 'delete' );
                                      
                                                  if ( is_wp_error( $order_id ) ) {
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 1 day to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1723..1758

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 271.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function get_orders_count( $status = null, $filter = array() ) {
                                      
                                              try {
                                                  if ( ! current_user_can( 'read_private_shop_orders' ) ) {
                                                      throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_orders_count', __( 'You do not have permission to read the orders count', 'woocommerce' ), 401 );
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 1 day to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 295..328

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 253.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Similar blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function get_variation_id( $product, $variations = array() ) {
                                              $variation_id = null;
                                              $variations_normalized = array();
                                      
                                              if ( $product->is_type( 'variable' ) && $product->has_child() ) {
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 7 hrs to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 968..997

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 235.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                                  $line_item = array(
                                                      'id'           => $item_id,
                                                      'subtotal'     => wc_format_decimal( $order->get_line_subtotal( $item, false, false ), $dp ),
                                                      'subtotal_tax' => wc_format_decimal( $item->get_subtotal_tax(), $dp ),
                                                      'total'        => wc_format_decimal( $order->get_line_total( $item, false, false ), $dp ),
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 6 hrs to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 224..237

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 223.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function get_order_notes( $order_id, $fields = null ) {
                                      
                                              // ensure ID is valid order ID
                                              $order_id = $this->validate_request( $order_id, $this->post_type, 'read' );
                                      
                                      
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 6 hrs to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1198..1227

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 219.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                                  if ( isset( $data['payment_details'] ) && is_array( $data['payment_details'] ) ) {
                                      
                                                      // method ID & title are required
                                                      if ( empty( $data['payment_details']['method_id'] ) || empty( $data['payment_details']['method_title'] ) ) {
                                                          throw new WC_API_Exception( 'woocommerce_invalid_payment_details', __( 'Payment method ID and title are required', 'woocommerce' ), 400 );
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 6 hrs to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 428..442

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 209.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function get_order_refunds( $order_id, $fields = null ) {
                                      
                                              // Ensure ID is valid order ID
                                              $order_id = $this->validate_request( $order_id, $this->post_type, 'read' );
                                      
                                      
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 4 hrs to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 1464..1486

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 163.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function get_orders( $fields = null, $filter = array(), $status = null, $page = 1 ) {
                                      
                                              if ( ! empty( $status ) ) {
                                                  $filter['status'] = $status;
                                              }
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 3 hrs to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 106..130

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 157.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          protected function set_item( $order, $item_type, $item, $action ) {
                                              global $wpdb;
                                      
                                              $set_method = "set_{$item_type}";
                                      
                                      
                                      Severity: Major
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 3 hrs to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 829..849

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 149.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      Identical blocks of code found in 2 locations. Consider refactoring.
                                      Open

                                          public function delete_order( $id, $force = false ) {
                                      
                                              $id = $this->validate_request( $id, $this->post_type, 'delete' );
                                      
                                              if ( is_wp_error( $id ) ) {
                                      Severity: Minor
                                      Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 55 mins to fix
                                      includes/legacy/api/v2/class-wc-api-orders.php on lines 647..660

                                      Duplicated Code

                                      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                      Tuning

                                      This issue has a mass of 98.

                                      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                      Refactorings

                                      Further Reading

                                      There are no issues that match your filters.

                                      Category
                                      Status