woothemes/woocommerce

View on GitHub
includes/class-wc-shipping-zone.php

Summary

Maintainability
C
1 day
Test Coverage

Function get_shipping_methods has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_shipping_methods( $enabled_only = false, $context = 'admin' ) {
        if ( null === $this->get_id() ) {
            return array();
        }

Severity: Minor
Found in includes/class-wc-shipping-zone.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

WC_Shipping_Zone has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class WC_Shipping_Zone extends WC_Legacy_Shipping_Zone {

    /**
     * Zone ID
     *
Severity: Minor
Found in includes/class-wc-shipping-zone.php - About 2 hrs to fix

    Method get_shipping_methods has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function get_shipping_methods( $enabled_only = false, $context = 'admin' ) {
            if ( null === $this->get_id() ) {
                return array();
            }
    
    
    Severity: Minor
    Found in includes/class-wc-shipping-zone.php - About 1 hr to fix

      Method get_formatted_location has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function get_formatted_location( $max = 10, $context = 'view' ) {
              $location_parts = array();
              $all_continents = WC()->countries->get_continents();
              $all_countries  = WC()->countries->get_countries();
              $all_states     = WC()->countries->get_states();
      Severity: Minor
      Found in includes/class-wc-shipping-zone.php - About 1 hr to fix

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

            public function get_formatted_location( $max = 10, $context = 'view' ) {
                $location_parts = array();
                $all_continents = WC()->countries->get_continents();
                $all_countries  = WC()->countries->get_countries();
                $all_states     = WC()->countries->get_states();
        Severity: Minor
        Found in includes/class-wc-shipping-zone.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 __construct has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function __construct( $zone = null ) {
                if ( is_numeric( $zone ) && ! empty( $zone ) ) {
                    $this->set_id( $zone );
                } elseif ( is_object( $zone ) ) {
                    $this->set_id( $zone->zone_id );
        Severity: Minor
        Found in includes/class-wc-shipping-zone.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

        There are no issues that match your filters.

        Category
        Status