woothemes/woocommerce

View on GitHub

Showing 4,341 of 4,341 total issues

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

Identical blocks of code found in 2 locations. Consider refactoring.
Open

S2.define('jquery.select2',[
  'jquery',
  'jquery-mousewheel',

  './select2/core',
Severity: Major
Found in assets/js/selectWoo/selectWoo.js and 1 other location - About 2 days to fix
assets/js/selectWoo/selectWoo.full.js on lines 6509..6572

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 509.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

S2.define('jquery.select2',[
  'jquery',
  'jquery-mousewheel',

  './select2/core',
Severity: Major
Found in assets/js/selectWoo/selectWoo.full.js and 1 other location - About 2 days to fix
assets/js/selectWoo/selectWoo.js on lines 5798..5861

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 509.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

<?php
/**
 * WooCommerce countries
 *
 * @package WooCommerce\l10n
Severity: Major
Found in includes/class-wc-countries.php - About 2 days to fix

    Function prettyPhoto has 585 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        $.fn.prettyPhoto = function(pp_settings) {
            pp_settings = jQuery.extend({
                hook: 'rel', /* the attribute tag to use for prettyPhoto hooks. default: 'rel'. For HTML5, use "data-rel" or similar. */
                animation_speed: 'fast', /* fast/slow/normal */
                ajaxcallback: function() {},
    Severity: Major
    Found in assets/js/prettyPhoto/jquery.prettyPhoto.js - About 2 days to fix

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

      <?php
      /**
       * Installation related functions and actions.
       *
       * @package WooCommerce\Classes
      Severity: Major
      Found in includes/class-wc-install.php - About 2 days to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            'IN' => array( // Indian states.
                'AP' => __( 'Andhra Pradesh', 'woocommerce' ),
                'AR' => __( 'Arunachal Pradesh', 'woocommerce' ),
                'AS' => __( 'Assam', 'woocommerce' ),
                'BR' => __( 'Bihar', 'woocommerce' ),
        Severity: Major
        Found in i18n/states.php and 1 other location - About 2 days to fix
        i18n/states.php on lines 1096..1134

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 561.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

            'NG' => array( // Nigerian provinces.
                'AB' => __( 'Abia', 'woocommerce' ),
                'FC' => __( 'Abuja', 'woocommerce' ),
                'AD' => __( 'Adamawa', 'woocommerce' ),
                'AK' => __( 'Akwa Ibom', 'woocommerce' ),
        Severity: Major
        Found in i18n/states.php and 1 other location - About 2 days to fix
        i18n/states.php on lines 630..668

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 561.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

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

        <?php
        /**
         * WooCommerce API Orders Class
         *
         * Handles requests to the /orders endpoint
        Severity: Major
        Found in includes/legacy/api/v3/class-wc-api-orders.php - About 2 days to fix

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

          <?php
          /**
           * REST API Products controller
           *
           * Handles requests to the /products endpoint.

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    foreach ( $refund->get_items() as $item_id => $item ) {
                        $product      = $item->get_product();
                        $product_id   = 0;
                        $variation_id = 0;
                        $product_sku  = null;
            includes/rest-api/Controllers/Version1/class-wc-rest-orders-v1-controller.php on lines 175..237

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 539.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                    foreach ( $order->get_items() as $item_id => $item ) {
                        $product      = $item->get_product();
                        $product_id   = 0;
                        $variation_id = 0;
                        $product_sku  = null;
            includes/rest-api/Controllers/Version1/class-wc-rest-order-refunds-v1-controller.php on lines 147..209

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 539.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function output_fields has a Cognitive Complexity of 136 (exceeds 5 allowed). Consider refactoring.
            Open

                    public static function output_fields( $options ) {
                        foreach ( $options as $value ) {
                            if ( ! isset( $value['type'] ) ) {
                                continue;
                            }
            Severity: Minor
            Found in includes/admin/class-wc-admin-settings.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

            File abstract-wc-order.php has 1085 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            <?php
            /**
             * Abstract Order
             *
             * Handles generic order data and database interaction which is extended by both
            Severity: Major
            Found in includes/abstracts/abstract-wc-order.php - About 2 days to fix

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

              <?php
              /**
               * WooCommerce Admin Helper
               *
               * @package WooCommerce\Admin\Helper
              Severity: Major
              Found in includes/admin/helper/class-wc-helper.php - About 2 days to fix

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

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

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                      public function register_routes() {
                          register_rest_route( $this->namespace, '/' . $this->rest_base, array(
                              array(
                                  'methods'             => WP_REST_Server::READABLE,
                                  'callback'            => array( $this, 'get_items' ),
                  includes/rest-api/Controllers/Version2/class-wc-rest-coupons-v2-controller.php on lines 45..121

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 529.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                      public function register_routes() {
                          register_rest_route(
                              $this->namespace, '/' . $this->rest_base, array(
                                  array(
                                      'methods'             => WP_REST_Server::READABLE,
                  includes/rest-api/Controllers/Version1/class-wc-rest-coupons-v1-controller.php on lines 56..124

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 529.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Function prepare_object_for_database has a Cognitive Complexity of 132 (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

                  Identical blocks of code found in 2 locations. Consider refactoring.
                  Open

                      protected function set_fee( $order, $fee, $action ) {
                  
                          if ( 'create' === $action ) {
                  
                              // fee title is required
                  Severity: Major
                  Found in includes/legacy/api/v3/class-wc-api-orders.php and 1 other location - About 2 days to fix
                  includes/legacy/api/v2/class-wc-api-orders.php on lines 1077..1137

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 507.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language