woothemes/woocommerce

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

Summary

Maintainability
F
1 wk
Test Coverage

Function output_fields has a Cognitive Complexity of 136 (exceeds 5 allowed). Consider refactoring.
Open

        public static function output_fields( $options ) {
            foreach ( $options as $value ) {
                if ( ! isset( $value['type'] ) ) {
                    continue;
                }
Severity: Minor
Found in includes/admin/class-wc-admin-settings.php - About 2 days 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_fields has 417 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public static function output_fields( $options ) {
            foreach ( $options as $value ) {
                if ( ! isset( $value['type'] ) ) {
                    continue;
                }
Severity: Major
Found in includes/admin/class-wc-admin-settings.php - About 2 days to fix

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

    <?php
    /**
     * WooCommerce Admin Settings Class
     *
     * @package  WooCommerce\Admin
    Severity: Major
    Found in includes/admin/class-wc-admin-settings.php - About 1 day to fix

      Function save_fields has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring.
      Open

              public static function save_fields( $options, $data = null ) {
                  if ( is_null( $data ) ) {
                      $data = $_POST; // WPCS: input var okay, CSRF ok.
                  }
                  if ( empty( $data ) ) {
      Severity: Minor
      Found in includes/admin/class-wc-admin-settings.php - About 1 day 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 save_fields has 89 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              public static function save_fields( $options, $data = null ) {
                  if ( is_null( $data ) ) {
                      $data = $_POST; // WPCS: input var okay, CSRF ok.
                  }
                  if ( empty( $data ) ) {
      Severity: Major
      Found in includes/admin/class-wc-admin-settings.php - About 3 hrs to fix

        Function get_option has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

                public static function get_option( $option_name, $default = '' ) {
                    if ( ! $option_name ) {
                        return $default;
                    }
        
        
        Severity: Minor
        Found in includes/admin/class-wc-admin-settings.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

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

                public static function check_download_folder_protection() {
                    $upload_dir      = wp_get_upload_dir();
                    $downloads_path  = $upload_dir['basedir'] . '/woocommerce_uploads';
                    $download_method = get_option( 'woocommerce_file_download_method' );
                    $file_path       = $downloads_path . '/.htaccess';
        Severity: Minor
        Found in includes/admin/class-wc-admin-settings.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

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

                public static function get_field_description( $value ) {
                    $description  = '';
                    $tooltip_html = '';
        
                    if ( true === $value['desc_tip'] ) {
        Severity: Minor
        Found in includes/admin/class-wc-admin-settings.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 get_field_description has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                public static function get_field_description( $value ) {
                    $description  = '';
                    $tooltip_html = '';
        
                    if ( true === $value['desc_tip'] ) {
        Severity: Minor
        Found in includes/admin/class-wc-admin-settings.php - About 1 hr to fix

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

                  public static function show_messages() {
                      if ( count( self::$errors ) > 0 ) {
                          foreach ( self::$errors as $error ) {
                              echo '<div id="message" class="error inline"><p><strong>' . esc_html( $error ) . '</strong></p></div>';
                          }
          Severity: Minor
          Found in includes/admin/class-wc-admin-settings.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

          There are no issues that match your filters.

          Category
          Status