woothemes/woocommerce

View on GitHub

Showing 3,141 of 4,341 total issues

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

<?php
/**
 * REST API Customers controller
 *
 * Handles requests to the /customers endpoint.

    Method prepare_object_for_database has 288 lines of code (exceeds 25 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'] ) ) {

      Function getLostPoint has a Cognitive Complexity of 72 (exceeds 5 allowed). Consider refactoring.
      Open

          getLostPoint : function(qrCode) {
      
              var moduleCount = qrCode.getModuleCount();
      
              var lostPoint = 0;
      Severity: Minor
      Found in assets/js/jquery-qrcode/jquery.qrcode.js - 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 wc-order-functions.php has 631 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      <?php
      /**
       * WooCommerce Order Functions
       *
       * Functions for order specific things.
      Severity: Major
      Found in includes/wc-order-functions.php - About 1 day to fix

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

            protected function prepare_object_for_database( $request, $creating = false ) {
                if ( isset( $request['id'] ) ) {
                    $variation = wc_get_product( absint( $request['id'] ) );
                } else {
                    $variation = new WC_Product_Variation();

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

            public static function output( $post ) {
                wp_nonce_field( 'woocommerce_save_data', 'woocommerce_meta_nonce' );
        
                $coupon_id = absint( $post->ID );
                $coupon    = new WC_Coupon( $coupon_id );
        Severity: Major
        Found in includes/admin/meta-boxes/class-wc-meta-box-coupon-data.php - About 1 day to fix

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

          jQuery( function( $ ) {
          
          // Generated by CoffeeScript 1.7.1
          (function() {
            var cardFromNumber, cardFromType, cards, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlashAndSpace, hasTextSelected, luhnCheck, reFormatCVC, reFormatCardNumber, reFormatExpiry, reFormatNumeric, replaceFullWidthChars, restrictCVC, restrictCardNumber, restrictExpiry, restrictNumeric, safeVal, setCardType,
          Severity: Major
          Found in assets/js/jquery-payment/jquery.payment.js - About 1 day to fix

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

            /* ------------------------------------------------------------------------
                Class: prettyPhoto
                Use: Lightbox clone for jQuery
                Author: Stephane Caron (http://www.no-margin-for-errors.com)
                Version: 3.1.6
            Severity: Major
            Found in assets/js/prettyPhoto/jquery.prettyPhoto.js - About 1 day to fix

              File class-wc-admin-post-types.php has 610 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              <?php
              /**
               * Post Types Admin
               *
               * @package  WooCommerce\Admin
              Severity: Major
              Found in includes/admin/class-wc-admin-post-types.php - About 1 day to fix

                Method save_product_meta has 262 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function save_product_meta( $product, $data ) {
                        global $wpdb;
                
                        // Virtual.
                        if ( isset( $data['virtual'] ) ) {
                Severity: Major
                Found in includes/legacy/api/v3/class-wc-api-products.php - About 1 day to fix

                  Method save_product_meta has 258 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      protected function save_product_meta( $product, $data ) {
                          global $wpdb;
                  
                          // Virtual
                          if ( isset( $data['virtual'] ) ) {
                  Severity: Major
                  Found in includes/legacy/api/v2/class-wc-api-products.php - About 1 day to fix

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

                        protected function prepare_object_for_database( $request, $creating = false ) {
                            if ( isset( $request['id'] ) ) {
                                $variation = wc_get_product( absint( $request['id'] ) );
                            } else {
                                $variation = new WC_Product_Variation();

                    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 prepare_object_for_database has 256 lines of code (exceeds 25 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'] ) ) {

                      Function get_product_data has a Cognitive Complexity of 64 (exceeds 5 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.

                      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 add-to-cart-variation.js has 582 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      /*global wc_add_to_cart_variation_params */
                      ;(function ( $, window, document, undefined ) {
                          /**
                           * VariationForm class which handles variation forms and attributes.
                           */
                      Severity: Major
                      Found in assets/js/frontend/add-to-cart-variation.js - About 1 day to fix

                        File class-wc-admin-list-table-orders.php has 576 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        <?php
                        /**
                         * List tables: orders.
                         *
                         * @package WooCommerce\Admin
                        Severity: Major
                        Found in includes/admin/list-tables/class-wc-admin-list-table-orders.php - About 1 day to fix

                          Method get_item_schema has 244 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'      => 'customer',
                                      'type'       => 'object',

                            Function _setup_segments has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
                            Open

                                private function _setup_segments() {
                                    $this->databaseType  = self::GEOIP_COUNTRY_EDITION;
                                    $this->record_length = self::STANDARD_RECORD_LENGTH;
                            
                                    if ( $this->flags & self::GEOIP_SHARED_MEMORY ) {
                            Severity: Minor
                            Found in includes/class-wc-geo-ip.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

                            Function add_to_cart has a Cognitive Complexity of 62 (exceeds 5 allowed). Consider refactoring.
                            Open

                                public function add_to_cart( $product_id = 0, $quantity = 1, $variation_id = 0, $variation = array(), $cart_item_data = array() ) {
                                    try {
                                        $product_id   = absint( $product_id );
                                        $variation_id = absint( $variation_id );
                            
                            
                            Severity: Minor
                            Found in includes/class-wc-cart.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 checkout.js has 568 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            /* global wc_checkout_params */
                            jQuery( function( $ ) {
                            
                                // wc_checkout_params is required to continue, ensure the object exists
                                if ( typeof wc_checkout_params === 'undefined' ) {
                            Severity: Major
                            Found in assets/js/frontend/checkout.js - About 1 day to fix
                              Severity
                              Category
                              Status
                              Source
                              Language