woothemes/woocommerce

View on GitHub
includes/widgets/class-wc-widget-price-filter.php

Summary

Maintainability
B
5 hrs
Test Coverage

Method widget has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function widget( $args, $instance ) {
        global $wp;

        // Requires lookup table added in 3.6.
        if ( version_compare( get_option( 'woocommerce_db_version', null ), '3.6', '<' ) ) {
Severity: Minor
Found in includes/widgets/class-wc-widget-price-filter.php - About 1 hr to fix

    Method __construct has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function __construct() {
            $this->widget_cssclass    = 'woocommerce widget_price_filter';
            $this->widget_description = __( 'Display a slider to filter products in your store by price.', 'woocommerce' );
            $this->widget_id          = 'woocommerce_price_filter';
            $this->widget_name        = __( 'Filter Products by Price', 'woocommerce' );
    Severity: Minor
    Found in includes/widgets/class-wc-widget-price-filter.php - About 1 hr to fix

      Method get_filtered_price has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function get_filtered_price() {
              global $wpdb;
      
              $args       = WC()->query->get_main_query()->query_vars;
              $tax_query  = isset( $args['tax_query'] ) ? $args['tax_query'] : array();
      Severity: Minor
      Found in includes/widgets/class-wc-widget-price-filter.php - About 1 hr to fix

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

            public function widget( $args, $instance ) {
                global $wp;
        
                // Requires lookup table added in 3.6.
                if ( version_compare( get_option( 'woocommerce_db_version', null ), '3.6', '<' ) ) {
        Severity: Minor
        Found in includes/widgets/class-wc-widget-price-filter.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_filtered_price has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function get_filtered_price() {
                global $wpdb;
        
                $args       = WC()->query->get_main_query()->query_vars;
                $tax_query  = isset( $args['tax_query'] ) ? $args['tax_query'] : array();
        Severity: Minor
        Found in includes/widgets/class-wc-widget-price-filter.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