woocommerce/woocommerce

View on GitHub

Showing 3,141 of 4,341 total issues

File jquery.qrcode.js has 915 lines of code (exceeds 250 allowed). Consider refactoring.
Open

//---------------------------------------------------------------------
// QRCode for JavaScript
//
// Copyright (c) 2009 Kazuhiko Arase
//
Severity: Major
Found in assets/js/jquery-qrcode/jquery.qrcode.js - About 2 days to fix

    Function set_product_meta has a Cognitive Complexity of 110 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function set_product_meta( $product, $request ) {
            // Virtual.
            if ( isset( $request['virtual'] ) ) {
                $product->set_virtual( $request['virtual'] );
            }
    Severity: Minor
    Found in includes/legacy/api/class-wc-rest-legacy-products-controller.php - About 2 days 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_product_meta has a Cognitive Complexity of 110 (exceeds 5 allowed). Consider refactoring.
    Open

        protected function set_product_meta( $product, $request ) {
            // Virtual.
            if ( isset( $request['virtual'] ) ) {
                $product->set_virtual( $request['virtual'] );
            }

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

    class WC_Cart extends WC_Legacy_Cart {
    
        /**
         * Contains an array of cart items.
         *
    Severity: Major
    Found in includes/class-wc-cart.php - About 2 days to fix

      Method output_fields has 417 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public static function output_fields( $options ) {
                  foreach ( $options as $value ) {
                      if ( ! isset( $value['type'] ) ) {
                          continue;
                      }
      Severity: Major
      Found in includes/admin/class-wc-admin-settings.php - About 2 days to fix

        Function setup has 414 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function setup($) {
                $.fn._fadeIn = $.fn.fadeIn;
        
                var noOp = $.noop || function() {};
        
        
        Severity: Major
        Found in assets/js/jquery-blockui/jquery.blockUI.js - About 2 days to fix

          Function nfx has a Cognitive Complexity of 100 (exceeds 5 allowed). Consider refactoring.
          Open

                  private static function nfx( $expr ) {
          
                      $index = 0;
                      $stack = new WC_Eval_Math_Stack;
                      $output = array(); // postfix form of expression, to be passed to pfx()
          Severity: Minor
          Found in includes/libraries/class-wc-eval-math.php - About 2 days to fix

          Cognitive Complexity

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

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

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

          Further reading

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

          <?php
          /**
           * WooCommerce product base class.
           *
           * @package WooCommerce\Abstracts
          Severity: Major
          Found in includes/abstracts/abstract-wc-product.php - About 1 day to fix

            WC_Abstract_Order has 98 functions (exceeds 20 allowed). Consider refactoring.
            Open

            abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
                use WC_Item_Totals;
            
                /**
                 * Order Data array. This is the core order data exposed in APIs since 3.0.0.
            Severity: Major
            Found in includes/abstracts/abstract-wc-order.php - About 1 day to fix

              Function output has a Cognitive Complexity of 90 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function output( $post ) {
                      global $theorder;
              
                      if ( ! is_object( $theorder ) ) {
                          $theorder = wc_get_order( $post->ID );
              Severity: Minor
              Found in includes/admin/meta-boxes/class-wc-meta-box-order-data.php - About 1 day to fix

              Cognitive Complexity

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

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

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

              Further reading

              File class-wc-rest-product-reviews-controller.php has 765 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              /**
               * REST API Product Reviews Controller
               *
               * Handles requests to /products/reviews.

                File class-wc-rest-product-variations-v2-controller.php has 753 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                /**
                 * REST API variations controller
                 *
                 * Handles requests to the /products/<product_id>/variations endpoints.

                  File class-wc-form-handler.php has 747 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  /**
                   * Handle frontend forms.
                   *
                   * @package WooCommerce\Classes\
                  Severity: Major
                  Found in includes/class-wc-form-handler.php - About 1 day to fix

                    Method query_report_data has 347 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function query_report_data() {
                            $this->report_data = new stdClass();
                    
                            $this->report_data->order_counts = (array) $this->get_order_report_data(
                                array(
                    Severity: Major
                    Found in includes/admin/reports/class-wc-report-sales-by-date.php - About 1 day to fix

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

                          public function get_item_schema() {
                              $weight_unit    = get_option( 'woocommerce_weight_unit' );
                              $dimension_unit = get_option( 'woocommerce_dimension_unit' );
                              $schema         = array(
                                  '$schema'    => 'http://json-schema.org/draft-04/schema#',

                        File class-wc-checkout.php has 744 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        <?php
                        /**
                         * Checkout functionality
                         *
                         * The WooCommerce checkout class handles the checkout process, collecting user data and processing the payment.
                        Severity: Major
                        Found in includes/class-wc-checkout.php - About 1 day to fix

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

                              public function get_item_schema() {
                                  $weight_unit    = get_option( 'woocommerce_weight_unit' );
                                  $dimension_unit = get_option( 'woocommerce_dimension_unit' );
                                  $schema         = array(
                                      '$schema'    => 'http://json-schema.org/draft-04/schema#',

                            Function save_variations has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
                            Open

                                protected function save_variations( $product, $request ) {
                                    global $wpdb;
                            
                                    $id         = $product->get_id();
                                    $variations = $request['variations'];
                            Severity: Minor
                            Found in includes/legacy/api/v3/class-wc-api-products.php - About 1 day to fix

                            Cognitive Complexity

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

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

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

                            Further reading

                            WC_AJAX has 90 functions (exceeds 20 allowed). Consider refactoring.
                            Open

                            class WC_AJAX {
                            
                                /**
                                 * Hook in ajax handlers.
                                 */
                            Severity: Major
                            Found in includes/class-wc-ajax.php - About 1 day to fix

                              Method get_settings has 341 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  public function get_settings( $current_section = '' ) {
                                      if ( 'inventory' === $current_section ) {
                                          $settings = apply_filters(
                                              'woocommerce_inventory_settings',
                                              array(
                              Severity: Major
                              Found in includes/admin/settings/class-wc-settings-products.php - About 1 day to fix
                                Severity
                                Category
                                Status
                                Source
                                Language