includes/shipping/legacy-local-pickup/class-wc-shipping-legacy-local-pickup.php
Method init_form_fields
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Enable', 'woocommerce' ),
'type' => 'checkbox',
Function is_valid_postcode
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
public function is_valid_postcode( $postcode, $country ) {
$codes = $this->get_valid_postcodes();
$postcode = $this->clean( $postcode );
$formatted_postcode = wc_format_postcode( $postcode, $country );
- 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 is_available
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
public function is_available( $package ) {
$is_available = 'yes' === $this->enabled;
if ( $is_available && $this->get_valid_postcodes() ) {
$is_available = $this->is_valid_postcode( $package['destination']['postcode'], $package['destination']['country'] );
- 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"