skyverge/wc-plugin-framework

View on GitHub
woocommerce/class-sv-wc-plugin-compatibility.php

Summary

Maintainability
C
7 hrs
Test Coverage

Consider simplifying this complex logical expression.
Open

if ( ! class_exists( '\\SkyVerge\\WooCommerce\\PluginFramework\\v5_12_3\\SV_WC_Plugin_Compatibility' ) ) :


/**
 * WooCommerce Compatibility Utility Class
Severity: Critical
Found in woocommerce/class-sv-wc-plugin-compatibility.php - About 3 hrs to fix

    Function get_latest_wc_versions has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function get_latest_wc_versions() {
    
            $latest_wc_versions = get_transient( 'sv_wc_plugin_wc_versions' );
    
            if ( ! is_array( $latest_wc_versions ) ) {
    Severity: Minor
    Found in woocommerce/class-sv-wc-plugin-compatibility.php - About 3 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

    Avoid deeply nested control flow statements.
    Open

                            if (
                                   is_string( $wc_version )
                                && '' !== $wc_version
                                && is_numeric( $wc_version[0] )
                                && false === strpos( $wc_version, '-' )
    Severity: Major
    Found in woocommerce/class-sv-wc-plugin-compatibility.php - About 45 mins to fix

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

          public static function convert_hr_to_bytes( $value ) {
      
              if ( function_exists( 'wp_convert_hr_to_bytes' ) ) {
      
                  return wp_convert_hr_to_bytes( $value );
      Severity: Minor
      Found in woocommerce/class-sv-wc-plugin-compatibility.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