woothemes/woocommerce

View on GitHub
includes/admin/helper/class-wc-helper-updater.php

Summary

Maintainability
D
2 days
Test Coverage

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

<?php
/**
 * The update helper for WooCommerce.com plugins.
 *
 * @class WC_Helper_Updater
Severity: Minor
Found in includes/admin/helper/class-wc-helper-updater.php - About 3 hrs to fix

    Method get_translations_update_data has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function get_translations_update_data() {
            $payload = array();
    
            $installed_translations = wp_get_installed_translations( 'plugins' );
    
    
    Severity: Major
    Found in includes/admin/helper/class-wc-helper-updater.php - About 2 hrs to fix

      Function get_translations_update_data has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function get_translations_update_data() {
              $payload = array();
      
              $installed_translations = wp_get_installed_translations( 'plugins' );
      
      
      Severity: Minor
      Found in includes/admin/helper/class-wc-helper-updater.php - About 2 hrs 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_updates_count has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          public static function get_updates_count() {
              $cache_key = '_woocommerce_helper_updates_count';
              $count     = get_transient( $cache_key );
              if ( false !== $count ) {
                  return $count;
      Severity: Minor
      Found in includes/admin/helper/class-wc-helper-updater.php - About 2 hrs 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_updates_count has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function get_updates_count() {
              $cache_key = '_woocommerce_helper_updates_count';
              $count     = get_transient( $cache_key );
              if ( false !== $count ) {
                  return $count;
      Severity: Minor
      Found in includes/admin/helper/class-wc-helper-updater.php - About 1 hr to fix

        Method transient_update_plugins has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function transient_update_plugins( $transient ) {
                $update_data = self::get_update_data();
        
                foreach ( WC_Helper::get_local_woo_plugins() as $plugin ) {
                    if ( empty( $update_data[ $plugin['_product_id'] ] ) ) {
        Severity: Minor
        Found in includes/admin/helper/class-wc-helper-updater.php - About 1 hr to fix

          Function transient_update_plugins has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function transient_update_plugins( $transient ) {
                  $update_data = self::get_update_data();
          
                  foreach ( WC_Helper::get_local_woo_plugins() as $plugin ) {
                      if ( empty( $update_data[ $plugin['_product_id'] ] ) ) {
          Severity: Minor
          Found in includes/admin/helper/class-wc-helper-updater.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 _update_check has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static function _update_check( $payload ) {
                  ksort( $payload );
                  $hash = md5( wp_json_encode( $payload ) );
          
                  $cache_key = '_woocommerce_helper_updates';
          Severity: Minor
          Found in includes/admin/helper/class-wc-helper-updater.php - About 1 hr to fix

            Function _has_active_subscription has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                private static function _has_active_subscription( $product_id ) {
                    if ( ! isset( $auth ) ) {
                        $auth = WC_Helper_Options::get( 'auth' );
                    }
            
            
            Severity: Minor
            Found in includes/admin/helper/class-wc-helper-updater.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 transient_update_themes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function transient_update_themes( $transient ) {
                    $update_data = self::get_update_data();
            
                    foreach ( WC_Helper::get_local_woo_themes() as $theme ) {
                        if ( empty( $update_data[ $theme['_product_id'] ] ) ) {
            Severity: Minor
            Found in includes/admin/helper/class-wc-helper-updater.php - About 55 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

            Function get_update_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public static function get_update_data() {
                    $payload = array();
            
                    // Scan subscriptions.
                    foreach ( WC_Helper::get_subscriptions() as $subscription ) {
            Severity: Minor
            Found in includes/admin/helper/class-wc-helper-updater.php - About 35 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

            Avoid too many return statements within this method.
            Open

                    return $translations;
            Severity: Major
            Found in includes/admin/helper/class-wc-helper-updater.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return $count;
              Severity: Major
              Found in includes/admin/helper/class-wc-helper-updater.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return array();
                Severity: Major
                Found in includes/admin/helper/class-wc-helper-updater.php - About 30 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status