Function is_available
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function is_available() {
$order = null;
$needs_shipping = false;
// Test if shipping is needed first.
- 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
Method init_form_fields
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'woocommerce' ),
'label' => __( 'Enable cash on delivery', 'woocommerce' ),
Function load_shipping_method_options
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
private function load_shipping_method_options() {
// Since this is expensive, we only want to do it if we're actually on the settings page.
if ( ! $this->is_accessing_settings() ) {
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
Function is_accessing_settings
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
private function is_accessing_settings() {
if ( is_admin() ) {
// phpcs:disable WordPress.Security.NonceVerification
if ( ! isset( $_REQUEST['page'] ) || 'wc-settings' !== $_REQUEST['page'] ) {
return false;
- 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
Method is_available
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function is_available() {
$order = null;
$needs_shipping = false;
// Test if shipping is needed first.
Method load_shipping_method_options
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function load_shipping_method_options() {
// Since this is expensive, we only want to do it if we're actually on the settings page.
if ( ! $this->is_accessing_settings() ) {
return array();
}
Function get_canonical_package_rate_ids
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function get_canonical_package_rate_ids( $chosen_package_rate_ids ) {
$shipping_packages = WC()->shipping()->get_packages();
$canonical_rate_ids = 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
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;