woothemes/woocommerce

View on GitHub
includes/class-wc-tracker.php

Summary

Maintainability
F
4 days
Test Coverage

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

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

<?php
/**
 * WooCommerce Tracker
 *
 * The WooCommerce tracker class adds functionality to track WooCommerce usage based on if the customer opted in.
Severity: Minor
Found in includes/class-wc-tracker.php - About 6 hrs to fix

    Method get_orders has 84 lines of code (exceeds 25 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: Major
    Found in includes/class-wc-tracker.php - About 3 hrs to fix

      WC_Tracker has 24 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class WC_Tracker {
      
          /**
           * URL to the WooThemes Tracker API endpoint.
           *
      Severity: Minor
      Found in includes/class-wc-tracker.php - About 2 hrs to fix

        Function get_all_template_overrides has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function get_all_template_overrides() {
                $override_data  = array();
                $template_paths = apply_filters( 'woocommerce_template_overrides_scan_paths', array( 'WooCommerce' => WC()->plugin_path() . '/templates/' ) );
                $scanned_files  = array();
        
        
        Severity: Minor
        Found in includes/class-wc-tracker.php - About 1 hr 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 get_all_plugins has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            private static function get_all_plugins() {
                // Ensure get_plugins function is loaded.
                if ( ! function_exists( 'get_plugins' ) ) {
                    include ABSPATH . '/wp-admin/includes/plugin.php';
                }
        Severity: Minor
        Found in includes/class-wc-tracker.php - About 1 hr 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_all_plugins has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private static function get_all_plugins() {
                // Ensure get_plugins function is loaded.
                if ( ! function_exists( 'get_plugins' ) ) {
                    include ABSPATH . '/wp-admin/includes/plugin.php';
                }
        Severity: Minor
        Found in includes/class-wc-tracker.php - About 1 hr to fix

          Method send_tracking_data has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function send_tracking_data( $override = false ) {
                  // Don't trigger this on AJAX Requests.
                  if ( Constants::is_true( 'DOING_AJAX' ) ) {
                      return;
                  }
          Severity: Minor
          Found in includes/class-wc-tracker.php - About 1 hr to fix

            Method get_review_counts has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private static function get_review_counts() {
                    global $wpdb;
                    $review_count = array( 'total' => 0 );
                    $status_map   = array(
                        '0'     => 'pending',
            Severity: Minor
            Found in includes/class-wc-tracker.php - About 1 hr to fix

              Method get_tracking_data has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private static function get_tracking_data() {
                      $data = array();
              
                      // General site info.
                      $data['url']   = home_url();
              Severity: Minor
              Found in includes/class-wc-tracker.php - About 1 hr to fix

                Method get_all_template_overrides has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private static function get_all_template_overrides() {
                        $override_data  = array();
                        $template_paths = apply_filters( 'woocommerce_template_overrides_scan_paths', array( 'WooCommerce' => WC()->plugin_path() . '/templates/' ) );
                        $scanned_files  = array();
                
                
                Severity: Minor
                Found in includes/class-wc-tracker.php - About 1 hr to fix

                  Function send_tracking_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public static function send_tracking_data( $override = false ) {
                          // Don't trigger this on AJAX Requests.
                          if ( Constants::is_true( 'DOING_AJAX' ) ) {
                              return;
                          }
                  Severity: Minor
                  Found in includes/class-wc-tracker.php - About 45 mins 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

                                  if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
                                      $theme_file = get_stylesheet_directory() . '/' . $file;
                                  } elseif ( file_exists( get_stylesheet_directory() . '/' . WC()->template_path() . $file ) ) {
                                      $theme_file = get_stylesheet_directory() . '/' . WC()->template_path() . $file;
                                  } elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
                  Severity: Major
                  Found in includes/class-wc-tracker.php and 1 other location - About 4 hrs to fix
                  includes/admin/class-wc-admin-notices.php on lines 323..331

                  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 171.

                  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

                  There are no issues that match your filters.

                  Category
                  Status