woothemes/woocommerce

View on GitHub
includes/admin/settings/class-wc-settings-shipping.php

Summary

Maintainability
C
1 day
Test Coverage

File class-wc-settings-shipping.php has 278 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WooCommerce Shipping Settings
 *
 * @package     WooCommerce\Admin
Severity: Minor
Found in includes/admin/settings/class-wc-settings-shipping.php - About 2 hrs to fix

    Method get_settings has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function get_settings( $current_section = '' ) {
            $settings = array();
    
            if ( '' === $current_section ) {
                $settings = apply_filters(
    Severity: Major
    Found in includes/admin/settings/class-wc-settings-shipping.php - About 2 hrs to fix

      Method zone_methods_screen has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function zone_methods_screen( $zone_id ) {
              if ( 'new' === $zone_id ) {
                  $zone = new WC_Shipping_Zone();
              } else {
                  $zone = WC_Shipping_Zones::get_zone( absint( $zone_id ) );
      Severity: Minor
      Found in includes/admin/settings/class-wc-settings-shipping.php - About 1 hr to fix

        Function output has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            public function output() {
                global $current_section, $hide_save_button;
        
                // Load shipping methods so we can show any global options they may have.
                $shipping_methods = WC()->shipping()->load_shipping_methods();
        Severity: Minor
        Found in includes/admin/settings/class-wc-settings-shipping.php - About 1 hr 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

        Method output_shipping_class_screen has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function output_shipping_class_screen() {
                $wc_shipping = WC_Shipping::instance();
                wp_localize_script(
                    'wc-shipping-classes',
                    'shippingClassesLocalizeScript',
        Severity: Minor
        Found in includes/admin/settings/class-wc-settings-shipping.php - About 1 hr to fix

          Method save has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function save() {
                  global $current_section;
          
                  switch ( $current_section ) {
                      case 'options':
          Severity: Minor
          Found in includes/admin/settings/class-wc-settings-shipping.php - About 1 hr to fix

            Function save has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                public function save() {
                    global $current_section;
            
                    switch ( $current_section ) {
                        case 'options':
            Severity: Minor
            Found in includes/admin/settings/class-wc-settings-shipping.php - About 55 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 get_sections has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function get_sections() {
                    $sections = array(
                        ''        => __( 'Shipping zones', 'woocommerce' ),
                        'options' => __( 'Shipping options', 'woocommerce' ),
                        'classes' => __( 'Shipping classes', 'woocommerce' ),
            Severity: Minor
            Found in includes/admin/settings/class-wc-settings-shipping.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 instance_settings_screen has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function instance_settings_screen( $instance_id ) {
                    $zone            = WC_Shipping_Zones::get_zone_by( 'instance_id', $instance_id );
                    $shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id );
            
                    if ( ! $shipping_method ) {
            Severity: Minor
            Found in includes/admin/settings/class-wc-settings-shipping.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 zone_methods_screen has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function zone_methods_screen( $zone_id ) {
                    if ( 'new' === $zone_id ) {
                        $zone = new WC_Shipping_Zone();
                    } else {
                        $zone = WC_Shipping_Zones::get_zone( absint( $zone_id ) );
            Severity: Minor
            Found in includes/admin/settings/class-wc-settings-shipping.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