woothemes/woocommerce

View on GitHub

Showing 3,141 of 4,341 total issues

Function validate_posted_data has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

    protected function validate_posted_data( &$data, &$errors ) {
        foreach ( $this->get_checkout_fields() as $fieldset_key => $fieldset ) {
            $validate_fieldset = true;
            if ( $this->maybe_skip_fieldset( $fieldset_key, $data ) ) {
                $validate_fieldset = false;
Severity: Minor
Found in includes/class-wc-checkout.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_Admin_Setup_Wizard has 64 functions (exceeds 20 allowed). Consider refactoring.
Open

class WC_Admin_Setup_Wizard {

    /**
     * Current step
     *
Severity: Major
Found in includes/admin/class-wc-admin-setup-wizard.php - About 1 day to fix

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

        public function get_settings() {
    
            $currency_code_options = get_woocommerce_currencies();
    
            foreach ( $currency_code_options as $code => $name ) {
    Severity: Major
    Found in includes/admin/settings/class-wc-settings-general.php - About 1 day to fix

      Method get_sales_report has 233 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function get_sales_report( $fields = null, $filter = array() ) {
      
              // check user permissions
              $check = $this->validate_request();
      
      
      Severity: Major
      Found in includes/legacy/api/v1/class-wc-api-reports.php - About 1 day to fix

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

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

          <?php
          /**
           * Post Types
           *
           * Registers post types and taxonomies.
          Severity: Major
          Found in includes/class-wc-post-types.php - About 1 day to fix

            Function get_orders has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function get_orders() {
                    $args = array(
                        'type'  => array( 'shop_order', 'shop_order_refund' ),
                        'limit' => get_option( 'posts_per_page' ),
                        'paged' => 1,
            Severity: Minor
            Found in includes/class-wc-tracker.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_Coupon has 62 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class WC_Coupon extends WC_Legacy_Coupon {
            
                /**
                 * Data array, with defaults.
                 *
            Severity: Major
            Found in includes/class-wc-coupon.php - About 1 day to fix

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

              <?php
              /**
               * Class WC_Email file.
               *
               * @package WooCommerce\Emails
              Severity: Major
              Found in includes/emails/class-wc-email.php - About 1 day to fix

                Function expand_data has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
                Open

                    protected function expand_data( $data ) {
                        $data = apply_filters( 'woocommerce_product_importer_pre_expand_data', $data );
                
                        // Images field maps to image and gallery id fields.
                        if ( isset( $data['images'] ) ) {
                Severity: Minor
                Found in includes/import/class-wc-product-csv-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

                Method render_helper_output has 221 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function render_helper_output() {
                        $auth           = WC_Helper_Options::get( 'auth' );
                        $auth_user_data = WC_Helper_Options::get( 'auth_user_data' );
                
                        // Return success/error notices.
                Severity: Major
                Found in includes/admin/helper/class-wc-helper.php - About 1 day to fix

                  Method get_schema has 220 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private static function get_schema() {
                          global $wpdb;
                  
                          $collate = '';
                  
                  
                  Severity: Major
                  Found in includes/class-wc-install.php - About 1 day to fix

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

                      Function save_fields has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
                      Open

                              public static function save_fields( $options, $data = null ) {
                                  if ( is_null( $data ) ) {
                                      $data = $_POST; // WPCS: input var okay, CSRF ok.
                                  }
                                  if ( empty( $data ) ) {
                      Severity: Minor
                      Found in includes/admin/class-wc-admin-settings.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-admin-addons.php has 528 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      /**
                       * Addons Page
                       *
                       * @package  WooCommerce\Admin
                      Severity: Major
                      Found in includes/admin/class-wc-admin-addons.php - About 1 day to fix

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

                        <?php
                        /**
                         * Deprecated functions
                         *
                         * Where functions come to die.
                        Severity: Major
                        Found in includes/wc-deprecated-functions.php - About 1 day to fix

                          Function render_helper_output has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
                          Open

                              public static function render_helper_output() {
                                  $auth           = WC_Helper_Options::get( 'auth' );
                                  $auth_user_data = WC_Helper_Options::get( 'auth_user_data' );
                          
                                  // Return success/error notices.
                          Severity: Minor
                          Found in includes/admin/helper/class-wc-helper.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 get_order_report_data has 214 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function get_order_report_data( $args = array() ) {
                                  global $wpdb;
                          
                                  $default_args = array(
                                      'data'                => array(),
                          Severity: Major
                          Found in includes/admin/reports/class-wc-admin-report.php - About 1 day to fix

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

                              File jquery.flot.pie.js has 522 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              /* Flot plugin for rendering pie charts.
                              
                              Copyright (c) 2007-2013 IOLA and Ole Laursen.
                              Licensed under the MIT license.
                              
                              
                              Severity: Major
                              Found in assets/js/jquery-flot/jquery.flot.pie.js - About 1 day to fix
                                Severity
                                Category
                                Status
                                Source
                                Language