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();
}
- Read upRead up
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
*
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();
}
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();
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();
- Read upRead up
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 );
- Read upRead up
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"