woothemes/woocommerce

View on GitHub

Showing 3,141 of 4,341 total issues

WC_API_Products has 59 functions (exceeds 20 allowed). Consider refactoring.
Open

class WC_API_Products extends WC_API_Resource {

    /** @var string $base the route base */
    protected $base = '/products';

Severity: Major
Found in includes/legacy/api/v3/class-wc-api-products.php - About 1 day to fix

    Function save_address has a Cognitive Complexity of 54 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function save_address() {
            global $wp;
    
            $nonce_value = wc_get_var( $_REQUEST['woocommerce-edit-address-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine.
    
    
    Severity: Minor
    Found in includes/class-wc-form-handler.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

    Method register_taxonomies has 210 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function register_taxonomies() {
    
            if ( ! is_blog_installed() ) {
                return;
            }
    Severity: Major
    Found in includes/class-wc-post-types.php - About 1 day to fix

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

      <?php
      /**
       * WooCommerce Customer Functions
       *
       * Functions for customers.
      Severity: Major
      Found in includes/wc-user-functions.php - About 1 day to fix

        File abstract-wc-settings-api.php has 514 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * Abstract Settings API Class
         *
         * Admin Settings API used by Integrations, Shipping Methods, and Payment Gateways.
        Severity: Major
        Found in includes/abstracts/abstract-wc-settings-api.php - About 1 day to fix

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

          /*global woocommerce_admin_meta_boxes */
          jQuery( function( $ ) {
          
              // Scroll to first checked category
              // https://github.com/scribu/wp-category-checklist-tree/blob/d1c3c1f449e1144542efa17dde84a9f52ade1739/category-checklist-tree.php
          Severity: Major
          Found in assets/js/admin/meta-boxes-product.js - About 1 day to fix

            Function set_product_data has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function set_product_data( &$product, $data ) {
                    if ( isset( $data['raw_attributes'] ) ) {
                        $attributes          = array();
                        $default_attributes  = array();
                        $existing_attributes = $product->get_attributes();
            Severity: Minor
            Found in includes/import/abstract-wc-product-importer.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-discounts.php has 510 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Discount calculation
             *
             * @package WooCommerce\Classes
            Severity: Major
            Found in includes/class-wc-discounts.php - About 1 day to fix

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

              <?php
              /**
               * Contains the query functions for WooCommerce which alter the front-end post queries and loops
               *
               * @version 3.2.0
              Severity: Major
              Found in includes/class-wc-query.php - About 1 day to fix

                File class-wc-report-sales-by-product.php has 507 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                <?php
                /**
                 * Sales By Product Reporting
                 *
                 * @package WooCommerce\Admin\Reporting
                Severity: Major
                Found in includes/admin/reports/class-wc-report-sales-by-product.php - About 1 day to fix

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

                  <?php
                  /**
                   * Abstract Rest Terms Controller
                   *
                   * @package WooCommerce\RestApi

                    Method get_main_chart has 203 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function get_main_chart() {
                            global $wp_locale;
                    
                            // Prepare data for report.
                            $data = array(
                    Severity: Major
                    Found in includes/admin/reports/class-wc-report-sales-by-date.php - About 1 day to fix

                      Method get_wp_query_args has 202 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          protected function get_wp_query_args( $query_vars ) {
                      
                              // Map query vars to ones that get_wp_query_args or WP_Query recognize.
                              $key_mapping = array(
                                  'status'         => 'post_status',
                      Severity: Major
                      Found in includes/data-stores/class-wc-product-data-store-cpt.php - About 1 day to fix

                        Method get_product_data has 202 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function get_product_data( $product, $context = 'view' ) {
                                /*
                                 * @param WP_REST_Request $request Current request object. For backward compatibility, we pass this argument silently.
                                 *
                                 *  TODO: Refactor to fix this behavior when DI gets included to make it obvious and clean.

                          File class-wc-meta-box-order-data.php has 498 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          <?php
                          /**
                           * Order Data
                           *
                           * Functions for displaying the order data meta box.
                          Severity: Minor
                          Found in includes/admin/meta-boxes/class-wc-meta-box-order-data.php - About 7 hrs to fix

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

                            <?php
                            /**
                             * WooCommerce coupons.
                             *
                             * The WooCommerce coupons class gets coupon data from storage and checks coupon validity.
                            Severity: Minor
                            Found in includes/class-wc-coupon.php - About 7 hrs to fix

                              Method set_product_meta has 197 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  protected function set_product_meta( $product, $request ) {
                                      // Virtual.
                                      if ( isset( $request['virtual'] ) ) {
                                          $product->set_virtual( $request['virtual'] );
                                      }
                              Severity: Major
                              Found in includes/legacy/api/class-wc-rest-legacy-products-controller.php - About 7 hrs to fix

                                Method set_product_meta has 197 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

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

                                  File class-wc-admin-report.php has 492 lines of code (exceeds 250 allowed). Consider refactoring.
                                  Open

                                  <?php
                                  
                                  if ( ! defined( 'ABSPATH' ) ) {
                                      exit; // Exit if accessed directly
                                  }
                                  Severity: Minor
                                  Found in includes/admin/reports/class-wc-admin-report.php - About 7 hrs to fix

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

                                    <?php
                                    /**
                                     * Webhook
                                     *
                                     * This class handles storing and retrieving webhook data from the associated.
                                    Severity: Minor
                                    Found in includes/class-wc-webhook.php - About 7 hrs to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language