woothemes/woocommerce

View on GitHub
includes/widgets/class-wc-widget-layered-nav.php

Summary

Maintainability
D
2 days
Test Coverage

Function layered_nav_list has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

    protected function layered_nav_list( $terms, $taxonomy, $query_type ) {
        // List display.
        echo '<ul class="woocommerce-widget-layered-nav-list">';

        $term_counts        = $this->get_filtered_term_product_counts( wp_list_pluck( $terms, 'term_id' ), $taxonomy, $query_type );
Severity: Minor
Found in includes/widgets/class-wc-widget-layered-nav.php - About 4 hrs 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

File class-wc-widget-layered-nav.php has 316 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Layered nav widget
 *
 * @package WooCommerce\Widgets
Severity: Minor
Found in includes/widgets/class-wc-widget-layered-nav.php - About 3 hrs to fix

    Method layered_nav_dropdown has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        protected function layered_nav_dropdown( $terms, $taxonomy, $query_type ) {
            global $wp;
            $found = false;
    
            if ( $taxonomy !== $this->get_current_taxonomy() ) {
    Severity: Major
    Found in includes/widgets/class-wc-widget-layered-nav.php - About 2 hrs to fix

      Function layered_nav_dropdown has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function layered_nav_dropdown( $terms, $taxonomy, $query_type ) {
              global $wp;
              $found = false;
      
              if ( $taxonomy !== $this->get_current_taxonomy() ) {
      Severity: Minor
      Found in includes/widgets/class-wc-widget-layered-nav.php - About 2 hrs 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 layered_nav_list has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function layered_nav_list( $terms, $taxonomy, $query_type ) {
              // List display.
              echo '<ul class="woocommerce-widget-layered-nav-list">';
      
              $term_counts        = $this->get_filtered_term_product_counts( wp_list_pluck( $terms, 'term_id' ), $taxonomy, $query_type );
      Severity: Major
      Found in includes/widgets/class-wc-widget-layered-nav.php - About 2 hrs to fix

        Method get_filtered_term_product_counts has 51 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function get_filtered_term_product_counts( $term_ids, $taxonomy, $query_type ) {
                global $wpdb;
        
                $tax_query  = $this->get_main_tax_query();
                $meta_query = $this->get_main_meta_query();
        Severity: Major
        Found in includes/widgets/class-wc-widget-layered-nav.php - About 2 hrs to fix

          Method init_settings has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function init_settings() {
                  $attribute_array      = array();
                  $std_attribute        = '';
                  $attribute_taxonomies = wc_get_attribute_taxonomies();
          
          
          Severity: Minor
          Found in includes/widgets/class-wc-widget-layered-nav.php - About 1 hr to fix

            Function get_filtered_term_product_counts has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

                protected function get_filtered_term_product_counts( $term_ids, $taxonomy, $query_type ) {
                    global $wpdb;
            
                    $tax_query  = $this->get_main_tax_query();
                    $meta_query = $this->get_main_meta_query();
            Severity: Minor
            Found in includes/widgets/class-wc-widget-layered-nav.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 widget has 32 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function widget( $args, $instance ) {
                    if ( ! is_shop() && ! is_product_taxonomy() ) {
                        return;
                    }
            
            
            Severity: Minor
            Found in includes/widgets/class-wc-widget-layered-nav.php - About 1 hr to fix

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

                  public function widget( $args, $instance ) {
                      if ( ! is_shop() && ! is_product_taxonomy() ) {
                          return;
                      }
              
              
              Severity: Minor
              Found in includes/widgets/class-wc-widget-layered-nav.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_instance_taxonomy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function get_instance_taxonomy( $instance ) {
                      if ( isset( $instance['attribute'] ) ) {
                          return wc_attribute_taxonomy_name( $instance['attribute'] );
                      }
              
              
              Severity: Minor
              Found in includes/widgets/class-wc-widget-layered-nav.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 init_settings has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function init_settings() {
                      $attribute_array      = array();
                      $std_attribute        = '';
                      $attribute_taxonomies = wc_get_attribute_taxonomies();
              
              
              Severity: Minor
              Found in includes/widgets/class-wc-widget-layered-nav.php - About 25 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