skyverge/wc-plugin-framework

View on GitHub
woocommerce/class-sv-wc-helper.php

Summary

Maintainability
F
4 days
Test Coverage

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

<?php
/**
 * WooCommerce Plugin Framework
 *
 * This source file is subject to the GNU General Public License v3.0
Severity: Minor
Found in woocommerce/class-sv-wc-helper.php - About 6 hrs to fix

    Function array_to_xml has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function array_to_xml( $xml_writer, $element_key, $element_value = array() ) {
    
            if ( is_array( $element_value ) ) {
    
                // handle attributes
    Severity: Minor
    Found in woocommerce/class-sv-wc-helper.php - About 5 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

    SV_WC_Helper has 36 functions (exceeds 20 allowed). Consider refactoring.
    Open

    #[\AllowDynamicProperties]
    class SV_WC_Helper {
    
    
        /** encoding used for mb_*() string functions */
    Severity: Minor
    Found in woocommerce/class-sv-wc-helper.php - About 4 hrs to fix

      Method render_select2_ajax has 96 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function render_select2_ajax() {
      
              if ( ! did_action( 'sv_wc_select2_ajax_rendered' ) ) {
      
                  $javascript = "( function(){
      Severity: Major
      Found in woocommerce/class-sv-wc-helper.php - About 3 hrs to fix

        Consider simplifying this complex logical expression.
        Open

        if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_12_4\\SV_WC_Helper' ) ) :
        
        
        /**
         * SkyVerge Helper Class
        Severity: Critical
        Found in woocommerce/class-sv-wc-helper.php - About 2 hrs to fix

          Function get_order_line_items has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function get_order_line_items( $order ): array {
          
                  $line_items = [];
          
                  /** @var \WC_Order_Item_Product $item */
          Severity: Minor
          Found in woocommerce/class-sv-wc-helper.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_order_line_items has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public static function get_order_line_items( $order ): array {
          
                  $line_items = [];
          
                  /** @var \WC_Order_Item_Product $item */
          Severity: Minor
          Found in woocommerce/class-sv-wc-helper.php - About 1 hr to fix

            Method array_to_xml has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function array_to_xml( $xml_writer, $element_key, $element_value = array() ) {
            
                    if ( is_array( $element_value ) ) {
            
                        // handle attributes
            Severity: Minor
            Found in woocommerce/class-sv-wc-helper.php - About 1 hr to fix

              Function str_exists has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function str_exists( $haystack, $needle ) {
              
                      if ( self::multibyte_loaded() ) {
              
                          if ( '' === $needle ) {
              Severity: Minor
              Found in woocommerce/class-sv-wc-helper.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 list_array_items has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function list_array_items( array $items, $conjunction = null, $separator = '' ) {
              
                      if ( ! is_string( $conjunction ) ) {
                          $conjunction = _x( 'and', 'coordinating conjunction for a list of items: a, b, and c', 'woocommerce-plugin-framework' );
                      }
              Severity: Minor
              Found in woocommerce/class-sv-wc-helper.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 str_starts_with has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function str_starts_with( $haystack, $needle ) {
              
                      if ( self::multibyte_loaded() ) {
              
                          if ( '' === $needle ) {
              Severity: Minor
              Found in woocommerce/class-sv-wc-helper.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 array_insert_after has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function array_insert_after( Array $array, $insert_key, Array $element ) {
              
                      $new_array = array();
              
                      foreach ( $array as $key => $value ) {
              Severity: Minor
              Found in woocommerce/class-sv-wc-helper.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 str_truncate has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function str_truncate( $string, $length, $omission = '...' ) {
              
                      if ( self::multibyte_loaded() ) {
              
                          // bail if string doesn't need to be truncated
              Severity: Minor
              Found in woocommerce/class-sv-wc-helper.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 trigger_error has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function trigger_error( $message, $type = E_USER_NOTICE ) {
              
                      if ( is_callable( 'wp_doing_ajax' ) && wp_doing_ajax() ) {
              
                          switch ( $type ) {
              Severity: Minor
              Found in woocommerce/class-sv-wc-helper.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

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

                  public static function array_join_natural( array $array, ?string $conjunction = 'and', ?string $pattern = '' ) : string
                  {
                      $last = array_pop( $array );
              
                      if ( $array ) {
              Severity: Minor
              Found in woocommerce/class-sv-wc-helper.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

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

                  public static function is_order_virtual( \WC_Order $order ) {
              
                      $is_virtual = true;
              
                      /** @var \WC_Order_Item_Product $item */
              Severity: Minor
              Found in woocommerce/class-sv-wc-helper.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

              Function is_rest_api_request has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function is_rest_api_request() {
              
                      if ( is_callable( 'WC' ) && is_callable( [ WC(), 'is_rest_api_request' ] ) ) {
                          return (bool) WC()->is_rest_api_request();
                      }
              Severity: Minor
              Found in woocommerce/class-sv-wc-helper.php - About 25 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

              There are no issues that match your filters.

              Category
              Status