woocommerce/woocommerce

View on GitHub

Showing 3,141 of 4,341 total issues

Method get_item_schema has 844 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',

    Method get_item_schema has 832 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 wc-update-functions.php has 1486 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * WooCommerce Updates
       *
       * Functions for updating data, used by the background updater.
      Severity: Major
      Found in includes/wc-update-functions.php - About 3 days to fix

        File class-wc-geo-ip.php has 1478 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * Geo IP class
         *
         * This class is a fork of GeoIP class from MaxMind LLC.
        Severity: Major
        Found in includes/class-wc-geo-ip.php - About 3 days to fix

          File wc-core-functions.php has 1477 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          <?php
          /**
           * WooCommerce Core Functions
           *
           * General core functions available on both the front-end and admin.
          Severity: Major
          Found in includes/wc-core-functions.php - About 3 days to fix

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

            <?php
            /**
             * WooCommerce API Products Class
             *
             * Handles requests to the /products endpoint
            Severity: Major
            Found in includes/legacy/api/v2/class-wc-api-products.php - About 3 days to fix

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

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

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

                /*!
                 * jquery.zeroclipboard
                 * Bind to the `beforecopy`, `copy`, `aftercopy`, and `copy-error` events, custom DOM-like events for clipboard injection generated using jQuery's Special Events API and ZeroClipboard's Core module.
                 * Copyright (c) 2014 
                 * Licensed MIT
                Severity: Major
                Found in assets/js/zeroclipboard/jquery.zeroclipboard.js - About 3 days to fix

                  File class-wc-product-data-store-cpt.php has 1385 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  <?php
                  /**
                   * WC_Product_Data_Store_CPT class file.
                   *
                   * @package WooCommerce\Classes
                  Severity: Major
                  Found in includes/data-stores/class-wc-product-data-store-cpt.php - About 3 days to fix

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

                            public function get_country_locale() {
                                if ( empty( $this->locale ) ) {
                                    $this->locale = apply_filters(
                                        'woocommerce_get_country_locale',
                                        array(
                        Severity: Major
                        Found in includes/class-wc-countries.php - About 3 days to fix

                          Function PhotoSwipeUI_Default has 641 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                           function(pswp, framework) {
                          
                              var ui = this;
                              var _overlayUIUpdated = false,
                                  _controlsVisible = true,
                          Severity: Major
                          Found in assets/js/photoswipe/photoswipe-ui-default.js - About 3 days to fix

                            File meta-boxes-order.js has 1228 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            // eslint-disable-next-line max-len
                            /*global woocommerce_admin_meta_boxes, woocommerce_admin, accounting, woocommerce_admin_meta_boxes_order, wcSetClipboard, wcClearClipboard */
                            jQuery( function ( $ ) {
                            
                                // Stand-in wcTracks.recordEvent in case tracks is not available (for any reason).
                            Severity: Major
                            Found in assets/js/admin/meta-boxes-order.js - About 3 days to fix

                              WC_Product has 158 functions (exceeds 20 allowed). Consider refactoring.
                              Open

                              class WC_Product extends WC_Abstract_Legacy_Product {
                              
                                  /**
                                   * This is the name of this object type.
                                   *
                              Severity: Major
                              Found in includes/abstracts/abstract-wc-product.php - About 3 days to fix

                                Function prepare_object_for_database has a Cognitive Complexity of 153 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    protected function prepare_object_for_database( $request, $creating = false ) {
                                        $id = isset( $request['id'] ) ? absint( $request['id'] ) : 0;
                                
                                        // Type is the most important part here because we need to be using the correct class and methods.
                                        if ( isset( $request['type'] ) ) {

                                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_item_schema has 608 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#',

                                  Method get_item_schema has 603 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_product_meta has a Cognitive Complexity of 147 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        protected function save_product_meta( $product, $data ) {
                                            global $wpdb;
                                    
                                            // Virtual.
                                            if ( isset( $data['virtual'] ) ) {
                                    Severity: Minor
                                    Found in includes/legacy/api/v3/class-wc-api-products.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 save_product_meta has a Cognitive Complexity of 146 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        protected function save_product_meta( $product, $data ) {
                                            global $wpdb;
                                    
                                            // Virtual
                                            if ( isset( $data['virtual'] ) ) {
                                    Severity: Minor
                                    Found in includes/legacy/api/v2/class-wc-api-products.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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language