woothemes/woocommerce

View on GitHub

Showing 3,141 of 4,341 total issues

Function save_variations_data has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
Open

    protected function save_variations_data( $product, $request ) {
        foreach ( $request['variations'] as $menu_order => $data ) {
            $variation = new WC_Product_Variation( isset( $data['id'] ) ? absint( $data['id'] ) : 0 );

            // Create initial name and status.
Severity: Minor
Found in includes/legacy/api/class-wc-rest-legacy-products-controller.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 save_variations_data has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
Open

    protected function save_variations_data( $product, $request ) {
        foreach ( $request['variations'] as $menu_order => $data ) {
            $variation = new WC_Product_Variation( isset( $data['id'] ) ? absint( $data['id'] ) : 0 );

            // Create initial name and status.

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

        public function admin_scripts() {
            global $wp_query, $post;

            $screen       = get_current_screen();
            $screen_id    = $screen ? $screen->id : '';
Severity: Major
Found in includes/admin/class-wc-admin-assets.php - About 1 day to fix

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

    <?php
    /**
     * WC_Order_Data_Store_CPT class file.
     *
     * @package WooCommerce\Classes
    Severity: Major
    Found in includes/data-stores/class-wc-order-data-store-cpt.php - About 1 day to fix

      WC_Customer has 88 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class WC_Customer extends WC_Legacy_Customer {
      
          /**
           * Stores customer data.
           *
      Severity: Major
      Found in includes/class-wc-customer.php - About 1 day to fix

        File class-wc-shop-customizer.php has 720 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        /**
         * Adds options to the customizer for WooCommerce.
         *
         * @version 3.3.0
        Severity: Major
        Found in includes/customizer/class-wc-shop-customizer.php - About 1 day to fix

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

          <?php
          /**
           * WC_Report_Sales_By_Date
           *
           * @package     WooCommerce\Admin\Reports
          Severity: Major
          Found in includes/admin/reports/class-wc-report-sales-by-date.php - About 1 day to fix

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

                protected function save_variations( $product, $request ) {
                    global $wpdb;
            
                    $id         = $product->get_id();
                    $attributes = $product->get_attributes();
            Severity: Minor
            Found in includes/legacy/api/v2/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

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

            <?php
            /**
             * WooCommerce Formatting
             *
             * Functions for formatting data.
            Severity: Major
            Found in includes/wc-formatting-functions.php - About 1 day to fix

              Method output has 321 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                Function wc_save_order_items has a Cognitive Complexity of 80 (exceeds 5 allowed). Consider refactoring.
                Open

                function wc_save_order_items( $order_id, $items ) {
                    // Allow other plugins to check change in order items before they are saved.
                    do_action( 'woocommerce_before_save_order_items', $order_id, $items );
                
                    $qty_change_order_notes = array();
                Severity: Minor
                Found in includes/admin/wc-admin-functions.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 woocommerce_form_field has a Cognitive Complexity of 78 (exceeds 5 allowed). Consider refactoring.
                Open

                    function woocommerce_form_field( $key, $args, $value = null ) {
                        $defaults = array(
                            'type'              => 'text',
                            'label'             => '',
                            'description'       => '',
                Severity: Minor
                Found in includes/wc-template-functions.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_settings has 309 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function get_settings( $current_section = '' ) {
                        $settings = array();
                
                        if ( '' === $current_section ) {
                            $settings = apply_filters(
                Severity: Major
                Found in includes/admin/settings/class-wc-settings-advanced.php - About 1 day to fix

                  Function order_pay has a Cognitive Complexity of 76 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private static function order_pay( $order_id ) {
                  
                          do_action( 'before_woocommerce_pay' );
                  
                          $order_id = absint( $order_id );
                  Severity: Minor
                  Found in includes/shortcodes/class-wc-shortcode-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

                  File class-wc-rest-product-variations-controller.php has 669 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-tax.php has 667 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    <?php
                    /**
                     * Tax calculation and rate finding class.
                     *
                     * @package WooCommerce\Classes
                    Severity: Major
                    Found in includes/class-wc-tax.php - About 1 day to fix

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

                      /* global wp, woocommerce_admin_meta_boxes_variations, woocommerce_admin, accounting */
                      jQuery( function( $ ) {
                          'use strict';
                      
                          /**
                      Severity: Major
                      Found in assets/js/admin/meta-boxes-product-variation.js - About 1 day to fix

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

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

                          File photoswipe-ui-default.js has 656 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          /*! PhotoSwipe Default UI - 4.1.3 - 2019-01-08
                          * http://photoswipe.com
                          * Copyright (c) 2019 Dmitry Semenov; */
                          /**
                          *
                          Severity: Major
                          Found in assets/js/photoswipe/photoswipe-ui-default.js - About 1 day to fix

                            File class-wc-product-csv-importer.php has 652 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            <?php
                            /**
                             * WooCommerce Product CSV importer
                             *
                             * @package WooCommerce\Import
                            Severity: Major
                            Found in includes/import/class-wc-product-csv-importer.php - About 1 day to fix
                              Severity
                              Category
                              Status
                              Source
                              Language