woocommerce/woocommerce

View on GitHub
includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php

Summary

Maintainability
F
3 wks
Test Coverage

Method get_item_schema has 675 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function get_item_schema() {
        $schema = array(
            '$schema'    => 'http://json-schema.org/draft-04/schema#',
            'title'      => $this->post_type,
            'type'       => 'object',

    File class-wc-rest-orders-v1-controller.php has 1259 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * REST API Orders controller
     *
     * Handles requests to the /orders endpoint.

      Method prepare_item_for_response has 178 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function prepare_item_for_response( $post, $request ) {
              $order = wc_get_order( $post );
              $dp    = is_null( $request['dp'] ) ? wc_get_price_decimals() : absint( $request['dp'] );
      
              $data = array(

        Function prepare_item_for_response has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
        Open

            public function prepare_item_for_response( $post, $request ) {
                $order = wc_get_order( $post );
                $dp    = is_null( $request['dp'] ) ? wc_get_price_decimals() : absint( $request['dp'] );
        
                $data = array(

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

            protected function prepare_item_for_database( $request ) {
                $id        = isset( $request['id'] ) ? absint( $request['id'] ) : 0;
                $order     = new WC_Order( $id );
                $schema    = $this->get_item_schema();
                $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) );

        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_REST_Orders_V1_Controller has 25 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class WC_REST_Orders_V1_Controller extends WC_REST_Posts_Controller {
        
            /**
             * Endpoint namespace.
             *

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

              public function register_routes() {
                  register_rest_route( $this->namespace, '/' . $this->rest_base, array(
                      array(
                          'methods'             => WP_REST_Server::READABLE,
                          'callback'            => array( $this, 'get_items' ),

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

                protected function prepare_item_for_database( $request ) {
                    $id        = isset( $request['id'] ) ? absint( $request['id'] ) : 0;
                    $order     = new WC_Order( $id );
                    $schema    = $this->get_item_schema();
                    $data_keys = array_keys( array_filter( $schema['properties'], array( $this, 'filter_writable_props' ) ) );

              Method query_args has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function query_args( $args, $request ) {
                      global $wpdb;
              
                      // Set post_status.
                      if ( 'any' !== $request['status'] ) {

                Method get_collection_params has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function get_collection_params() {
                        $params = parent::get_collection_params();
                
                        $params['status'] = array(
                            'default'           => 'any',

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

                      public function query_args( $args, $request ) {
                          global $wpdb;
                  
                          // Set post_status.
                          if ( 'any' !== $request['status'] ) {

                  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

                  Consider simplifying this complex logical expression.
                  Open

                              if ( isset( $request['billing'] ) || isset( $request['shipping'] ) || isset( $request['line_items'] ) || isset( $request['shipping_lines'] ) || isset( $request['fee_lines'] ) || isset( $request['coupon_lines'] ) ) {
                                  $order->calculate_totals( true );
                              }

                    Function set_item has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                        protected function set_item( $order, $item_type, $posted ) {
                            global $wpdb;
                    
                            if ( ! empty( $posted['id'] ) ) {
                                $action = 'update';

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

                        protected function get_product_id( $posted, $action = 'create' ) {
                            if ( ! empty( $posted['sku'] ) ) {
                                $product_id = (int) wc_get_product_id_by_sku( $posted['sku'] );
                            } elseif ( ! empty( $posted['product_id'] ) && empty( $posted['variation_id'] ) ) {
                                $product_id = (int) $posted['product_id'];

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

                        protected function create_order( $request ) {
                            try {
                                // Make sure customer exists.
                                if ( ! is_null( $request['customer_id'] ) && 0 !== $request['customer_id'] && false === get_user_by( 'id', $request['customer_id'] ) ) {
                                    throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id',__( 'Customer ID is invalid.', 'woocommerce' ), 400 );

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

                        protected function update_order( $request ) {
                            try {
                                $order = $this->prepare_item_for_database( $request );
                                $order->save();
                    
                    

                    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

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

                            foreach ( $order->get_items() as $item_id => $item ) {
                                $product      = $item->get_product();
                                $product_id   = 0;
                                $variation_id = 0;
                                $product_sku  = null;
                    includes/rest-api/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php on lines 147..209

                    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 539.

                    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 3 locations. Consider refactoring.
                    Open

                        public function register_routes() {
                            register_rest_route( $this->namespace, '/' . $this->rest_base, array(
                                array(
                                    'methods'             => WP_REST_Server::READABLE,
                                    'callback'            => array( $this, 'get_items' ),
                    includes/rest-api/Controllers/Version1/class-wc-rest-taxes-v1-controller.php on lines 42..104
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 59..133

                    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 484.

                    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 5 locations. Consider refactoring.
                    Open

                                    'billing' => array(
                                        'description' => __( 'Billing address.', 'woocommerce' ),
                                        'type'        => 'object',
                                        'context'     => array( 'view', 'edit' ),
                                        'properties'  => array(
                    includes/rest-api/Controllers/Version1/class-wc-rest-customers-v1-controller.php on lines 722..784
                    includes/rest-api/Controllers/Version2/class-wc-rest-customers-v2-controller.php on lines 194..256
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 1091..1153
                    includes/rest-api/Controllers/Version3/class-wc-rest-customers-controller.php on lines 149..211

                    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

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

                                    'shipping' => array(
                                        'description' => __( 'Shipping address.', 'woocommerce' ),
                                        'type'        => 'object',
                                        'context'     => array( 'view', 'edit' ),
                                        'properties'  => array(
                    includes/rest-api/Controllers/Version1/class-wc-rest-customers-v1-controller.php on lines 785..836
                    includes/rest-api/Controllers/Version2/class-wc-rest-customers-v2-controller.php on lines 257..308
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 1154..1205
                    includes/rest-api/Controllers/Version3/class-wc-rest-customers-controller.php on lines 212..263

                    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 386.

                    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 create_order( $request ) {
                            try {
                                // Make sure customer exists.
                                if ( ! is_null( $request['customer_id'] ) && 0 !== $request['customer_id'] && false === get_user_by( 'id', $request['customer_id'] ) ) {
                                    throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id',__( 'Customer ID is invalid.', 'woocommerce' ), 400 );
                    includes/legacy/api/class-wc-rest-legacy-orders-controller.php on lines 245..274

                    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 301.

                    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 update_item( $request ) {
                            try {
                                $post_id = (int) $request['id'];
                    
                                if ( empty( $post_id ) || get_post_type( $post_id ) !== $this->post_type ) {
                    includes/rest-api/Controllers/Version1/class-wc-rest-coupons-v1-controller.php on lines 346..377

                    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 243.

                    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

                        protected function prepare_links( $order, $request ) {
                            $links = array(
                                'self' => array(
                                    'href' => rest_url( sprintf( '/%s/%s/%d', $this->namespace, $this->rest_base, $order->get_id() ) ),
                                ),
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 430..453

                    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 211.

                    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 10 locations. Consider refactoring.
                    Open

                                                'meta' => array(
                                                    'description' => __( 'Line item meta data.', 'woocommerce' ),
                                                    'type'        => 'array',
                                                    'context'     => array( 'view', 'edit' ),
                                                    'readonly'    => true,
                    includes/rest-api/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php on lines 445..473
                    includes/rest-api/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php on lines 474..502
                    includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php on lines 1281..1309
                    includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php on lines 1494..1522
                    includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php on lines 1558..1586
                    includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php on lines 494..522
                    includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php on lines 523..551
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 1632..1660
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 1748..1776

                    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 201.

                    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 10 locations. Consider refactoring.
                    Open

                                    'refunds' => array(
                                        'description' => __( 'List of refunds.', 'woocommerce' ),
                                        'type'        => 'array',
                                        'context'     => array( 'view', 'edit' ),
                                        'readonly'    => true,
                    includes/rest-api/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php on lines 445..473
                    includes/rest-api/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php on lines 474..502
                    includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php on lines 1281..1309
                    includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php on lines 1310..1338
                    includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php on lines 1494..1522
                    includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php on lines 494..522
                    includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php on lines 523..551
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 1632..1660
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 1748..1776

                    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 201.

                    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 10 locations. Consider refactoring.
                    Open

                                                'taxes' => array(
                                                    'description' => __( 'Line taxes.', 'woocommerce' ),
                                                    'type'        => 'array',
                                                    'context'     => array( 'view', 'edit' ),
                                                    'readonly'    => true,
                    includes/rest-api/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php on lines 445..473
                    includes/rest-api/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php on lines 474..502
                    includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php on lines 1310..1338
                    includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php on lines 1494..1522
                    includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php on lines 1558..1586
                    includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php on lines 494..522
                    includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php on lines 523..551
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 1632..1660
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 1748..1776

                    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 201.

                    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 10 locations. Consider refactoring.
                    Open

                                                'taxes' => array(
                                                    'description' => __( 'Line taxes.', 'woocommerce' ),
                                                    'type'        => 'array',
                                                    'context'     => array( 'view', 'edit' ),
                                                    'readonly'    => true,
                    includes/rest-api/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php on lines 445..473
                    includes/rest-api/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php on lines 474..502
                    includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php on lines 1281..1309
                    includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php on lines 1310..1338
                    includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php on lines 1558..1586
                    includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php on lines 494..522
                    includes/rest-api/Controllers/Version2/class-wc-rest-order-refunds-v2-controller.php on lines 523..551
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 1632..1660
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 1748..1776

                    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 201.

                    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

                                                'taxes' => array(
                                                    'description' => __( 'Line taxes.', 'woocommerce' ),
                                                    'type'        => 'array',
                                                    'context'     => array( 'view', 'edit' ),
                                                    'readonly'    => true,
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 1540..1562

                    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 155.

                    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 get_product_id( $posted, $action = 'create' ) {
                            if ( ! empty( $posted['sku'] ) ) {
                                $product_id = (int) wc_get_product_id_by_sku( $posted['sku'] );
                            } elseif ( ! empty( $posted['product_id'] ) && empty( $posted['variation_id'] ) ) {
                                $product_id = (int) $posted['product_id'];
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 698..711

                    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 154.

                    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 4 locations. Consider refactoring.
                    Open

                                        case 'coupon_lines' :
                                            if ( is_array( $value ) ) {
                                                foreach ( $value as $item ) {
                                                    if ( is_array( $item ) ) {
                                                        if ( $this->item_is_null( $item ) || ( isset( $item['quantity'] ) && 0 === $item['quantity'] ) ) {
                    includes/legacy/api/class-wc-rest-legacy-orders-controller.php on lines 184..196
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 568..580
                    includes/rest-api/Controllers/Version3/class-wc-rest-orders-controller.php on lines 97..109

                    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 99.

                    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 ( $product && $product !== $item->get_product() ) {
                                $item->set_product( $product );
                    
                                if ( 'create' === $action ) {
                                    $quantity = isset( $posted['quantity'] ) ? $posted['quantity'] : 1;
                    includes/rest-api/Controllers/Version2/class-wc-rest-orders-v2-controller.php on lines 769..778

                    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