WordPress/WordPress

View on GitHub
wp-includes/class-wp-query.php

Summary

Maintainability
F
1 mo
Test Coverage

Function get_posts has a Cognitive Complexity of 522 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_posts() {
        global $wpdb;

        $this->parse_query();

Severity: Minor
Found in wp-includes/class-wp-query.php - About 1 wk 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-wp-query.php has 2579 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Query API: WP_Query class
 *
 * @package WordPress
Severity: Major
Found in wp-includes/class-wp-query.php - About 1 wk to fix

    Method get_posts has 1027 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function get_posts() {
            global $wpdb;
    
            $this->parse_query();
    
    
    Severity: Major
    Found in wp-includes/class-wp-query.php - About 5 days to fix

      Function parse_query has a Cognitive Complexity of 161 (exceeds 5 allowed). Consider refactoring.
      Open

          public function parse_query( $query = '' ) {
              if ( ! empty( $query ) ) {
                  $this->init();
                  $this->query      = wp_parse_args( $query );
                  $this->query_vars = $this->query;
      Severity: Minor
      Found in wp-includes/class-wp-query.php - About 3 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 parse_query has 277 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function parse_query( $query = '' ) {
              if ( ! empty( $query ) ) {
                  $this->init();
                  $this->query      = wp_parse_args( $query );
                  $this->query_vars = $this->query;
      Severity: Major
      Found in wp-includes/class-wp-query.php - About 1 day to fix

        WP_Query has 68 functions (exceeds 20 allowed). Consider refactoring.
        Open

        #[AllowDynamicProperties]
        class WP_Query {
        
            /**
             * Query vars set by the user.
        Severity: Major
        Found in wp-includes/class-wp-query.php - About 1 day to fix

          Function parse_tax_query has a Cognitive Complexity of 61 (exceeds 5 allowed). Consider refactoring.
          Open

              public function parse_tax_query( &$q ) {
                  if ( ! empty( $q['tax_query'] ) && is_array( $q['tax_query'] ) ) {
                      $tax_query = $q['tax_query'];
                  } else {
                      $tax_query = array();
          Severity: Minor
          Found in wp-includes/class-wp-query.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 parse_tax_query has 189 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function parse_tax_query( &$q ) {
                  if ( ! empty( $q['tax_query'] ) && is_array( $q['tax_query'] ) ) {
                      $tax_query = $q['tax_query'];
                  } else {
                      $tax_query = array();
          Severity: Major
          Found in wp-includes/class-wp-query.php - About 7 hrs to fix

            Function get_queried_object has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
            Open

                public function get_queried_object() {
                    if ( isset( $this->queried_object ) ) {
                        return $this->queried_object;
                    }
            
            
            Severity: Minor
            Found in wp-includes/class-wp-query.php - About 7 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 parse_orderby has 103 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function parse_orderby( $orderby ) {
                    global $wpdb;
            
                    // Used to filter values.
                    $allowed_keys = array(
            Severity: Major
            Found in wp-includes/class-wp-query.php - About 4 hrs to fix

              Function parse_search has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function parse_search( &$q ) {
                      global $wpdb;
              
                      $search = '';
              
              
              Severity: Minor
              Found in wp-includes/class-wp-query.php - About 3 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

              Function parse_orderby has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected function parse_orderby( $orderby ) {
                      global $wpdb;
              
                      // Used to filter values.
                      $allowed_keys = array(
              Severity: Minor
              Found in wp-includes/class-wp-query.php - About 3 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 get_queried_object has 70 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function get_queried_object() {
                      if ( isset( $this->queried_object ) ) {
                          return $this->queried_object;
                      }
              
              
              Severity: Major
              Found in wp-includes/class-wp-query.php - About 2 hrs to fix

                Method parse_search has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    protected function parse_search( &$q ) {
                        global $wpdb;
                
                        $search = '';
                
                
                Severity: Major
                Found in wp-includes/class-wp-query.php - About 2 hrs to fix

                  Method fill_query_vars has 67 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function fill_query_vars( $query_vars ) {
                          $keys = array(
                              'error',
                              'm',
                              'p',
                  Severity: Major
                  Found in wp-includes/class-wp-query.php - About 2 hrs to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if ( ! ( $this->is_singular || $this->is_archive || $this->is_search || $this->is_feed
                                    || ( wp_is_serving_rest_request() && $this->is_main_query() )
                                    || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_robots || $this->is_favicon ) ) {
                                $this->is_home = true;
                            }
                    Severity: Critical
                    Found in wp-includes/class-wp-query.php - About 2 hrs to fix

                      Function is_single has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function is_single( $post = '' ) {
                              if ( ! $this->is_single ) {
                                  return false;
                              }
                      
                      
                      Severity: Minor
                      Found in wp-includes/class-wp-query.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

                      Function is_page has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function is_page( $page = '' ) {
                              if ( ! $this->is_page ) {
                                  return false;
                              }
                      
                      
                      Severity: Minor
                      Found in wp-includes/class-wp-query.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

                      Function generate_postdata has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                      Open

                          public function generate_postdata( $post ) {
                      
                              if ( ! ( $post instanceof WP_Post ) ) {
                                  $post = get_post( $post );
                              }
                      Severity: Minor
                      Found in wp-includes/class-wp-query.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 generate_postdata has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public function generate_postdata( $post ) {
                      
                              if ( ! ( $post instanceof WP_Post ) ) {
                                  $post = get_post( $post );
                              }
                      Severity: Major
                      Found in wp-includes/class-wp-query.php - About 2 hrs to fix

                        Function parse_search_order has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function parse_search_order( &$q ) {
                                global $wpdb;
                        
                                if ( $q['search_terms_count'] > 1 ) {
                                    $num_terms = count( $q['search_orderby_title'] );
                        Severity: Minor
                        Found in wp-includes/class-wp-query.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 generate_cache_key has 47 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            protected function generate_cache_key( array $args, $sql ) {
                                global $wpdb;
                        
                                unset(
                                    $args['cache_results'],
                        Severity: Minor
                        Found in wp-includes/class-wp-query.php - About 1 hr to fix

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

                              private function set_found_posts( $q, $limits ) {
                                  global $wpdb;
                          
                                  /*
                                   * Bail if posts is an empty array. Continue if posts is an empty string,
                          Severity: Minor
                          Found in wp-includes/class-wp-query.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 parse_search_terms has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                              protected function parse_search_terms( $terms ) {
                                  $strtolower = function_exists( 'mb_strtolower' ) ? 'mb_strtolower' : 'strtolower';
                                  $checked    = array();
                          
                                  $stopwords = $this->get_search_stopwords();
                          Severity: Minor
                          Found in wp-includes/class-wp-query.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 is_page has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              public function is_page( $page = '' ) {
                                  if ( ! $this->is_page ) {
                                      return false;
                                  }
                          
                          
                          Severity: Minor
                          Found in wp-includes/class-wp-query.php - About 1 hr to fix

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

                                public function is_single( $post = '' ) {
                                    if ( ! $this->is_single ) {
                                        return false;
                                    }
                            
                            
                            Severity: Minor
                            Found in wp-includes/class-wp-query.php - About 1 hr to fix

                              Method init_query_flags has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                  private function init_query_flags() {
                                      $this->is_single            = false;
                                      $this->is_preview           = false;
                                      $this->is_page              = false;
                                      $this->is_archive           = false;
                              Severity: Minor
                              Found in wp-includes/class-wp-query.php - About 1 hr to fix

                                Method parse_search_order has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                    protected function parse_search_order( &$q ) {
                                        global $wpdb;
                                
                                        if ( $q['search_terms_count'] > 1 ) {
                                            $num_terms = count( $q['search_orderby_title'] );
                                Severity: Minor
                                Found in wp-includes/class-wp-query.php - About 1 hr to fix

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

                                      protected function generate_cache_key( array $args, $sql ) {
                                          global $wpdb;
                                  
                                          unset(
                                              $args['cache_results'],
                                  Severity: Minor
                                  Found in wp-includes/class-wp-query.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

                                  Consider simplifying this complex logical expression.
                                  Open

                                              if ( $this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax ) {
                                                  $this->is_archive = true;
                                              }
                                  Severity: Major
                                  Found in wp-includes/class-wp-query.php - About 40 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                return true;
                                    Severity: Major
                                    Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                  return true;
                                      Severity: Major
                                      Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                    return true;
                                        Severity: Major
                                        Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                      return true;
                                          Severity: Major
                                          Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                    return false;
                                            Severity: Major
                                            Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                          return true;
                                              Severity: Major
                                              Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                            return true;
                                                Severity: Major
                                                Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                              return true;
                                                  Severity: Major
                                                  Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                            return false;
                                                    Severity: Major
                                                    Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                              return false;
                                                      Severity: Major
                                                      Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                    return true;
                                                        Severity: Major
                                                        Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                  return false;
                                                          Severity: Major
                                                          Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                                return true;
                                                            Severity: Major
                                                            Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                              Avoid too many return statements within this method.
                                                              Open

                                                                      return $this->posts;
                                                              Severity: Major
                                                              Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                                Avoid too many return statements within this method.
                                                                Open

                                                                        return isset( $queried_object->term_id ) &&
                                                                            count(
                                                                                array_intersect(
                                                                                    array( $queried_object->term_id, $queried_object->name, $queried_object->slug ),
                                                                                    $term_array
                                                                Severity: Major
                                                                Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                                  Avoid too many return statements within this method.
                                                                  Open

                                                                              return true;
                                                                  Severity: Major
                                                                  Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                                    Avoid too many return statements within this method.
                                                                    Open

                                                                            return false;
                                                                    Severity: Major
                                                                    Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                                      Avoid too many return statements within this method.
                                                                      Open

                                                                                  return true;
                                                                      Severity: Major
                                                                      Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                                        Avoid too many return statements within this method.
                                                                        Open

                                                                                            return true;
                                                                        Severity: Major
                                                                        Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                                          Avoid too many return statements within this method.
                                                                          Open

                                                                                      return true;
                                                                          Severity: Major
                                                                          Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                                            Avoid too many return statements within this method.
                                                                            Open

                                                                                        return true;
                                                                            Severity: Major
                                                                            Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                                              Avoid too many return statements within this method.
                                                                              Open

                                                                                      return false;
                                                                              Severity: Major
                                                                              Found in wp-includes/class-wp-query.php - About 30 mins to fix

                                                                                Function is_attachment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                Open

                                                                                    public function is_attachment( $attachment = '' ) {
                                                                                        if ( ! $this->is_attachment ) {
                                                                                            return false;
                                                                                        }
                                                                                
                                                                                
                                                                                Severity: Minor
                                                                                Found in wp-includes/class-wp-query.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

                                                                                Function is_tag has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                Open

                                                                                    public function is_tag( $tag = '' ) {
                                                                                        if ( ! $this->is_tag ) {
                                                                                            return false;
                                                                                        }
                                                                                
                                                                                
                                                                                Severity: Minor
                                                                                Found in wp-includes/class-wp-query.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

                                                                                Function fill_query_vars has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                Open

                                                                                    public function fill_query_vars( $query_vars ) {
                                                                                        $keys = array(
                                                                                            'error',
                                                                                            'm',
                                                                                            'p',
                                                                                Severity: Minor
                                                                                Found in wp-includes/class-wp-query.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

                                                                                Function is_author has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                Open

                                                                                    public function is_author( $author = '' ) {
                                                                                        if ( ! $this->is_author ) {
                                                                                            return false;
                                                                                        }
                                                                                
                                                                                
                                                                                Severity: Minor
                                                                                Found in wp-includes/class-wp-query.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

                                                                                Function is_category has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                Open

                                                                                    public function is_category( $category = '' ) {
                                                                                        if ( ! $this->is_category ) {
                                                                                            return false;
                                                                                        }
                                                                                
                                                                                
                                                                                Severity: Minor
                                                                                Found in wp-includes/class-wp-query.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

                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                Open

                                                                                        if ( ! $q['suppress_filters'] ) {
                                                                                            /**
                                                                                             * Filters the WHERE clause of the query.
                                                                                             *
                                                                                             * Specifically for manipulating paging queries.
                                                                                Severity: Major
                                                                                Found in wp-includes/class-wp-query.php and 1 other location - About 1 day to fix
                                                                                wp-includes/class-wp-query.php on lines 2981..3098

                                                                                Duplicated Code

                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                Tuning

                                                                                This issue has a mass of 373.

                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                Refactorings

                                                                                Further Reading

                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                Open

                                                                                        if ( ! $q['suppress_filters'] ) {
                                                                                            /**
                                                                                             * Filters the WHERE clause of the query.
                                                                                             *
                                                                                             * For use by caching plugins.
                                                                                Severity: Major
                                                                                Found in wp-includes/class-wp-query.php and 1 other location - About 1 day to fix
                                                                                wp-includes/class-wp-query.php on lines 2859..2964

                                                                                Duplicated Code

                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                Tuning

                                                                                This issue has a mass of 373.

                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                Refactorings

                                                                                Further Reading

                                                                                Similar blocks of code found in 3 locations. Consider refactoring.
                                                                                Open

                                                                                    public function is_author( $author = '' ) {
                                                                                        if ( ! $this->is_author ) {
                                                                                            return false;
                                                                                        }
                                                                                
                                                                                
                                                                                Severity: Major
                                                                                Found in wp-includes/class-wp-query.php and 2 other locations - About 4 hrs to fix
                                                                                wp-includes/class-wp-query.php on lines 4166..4191
                                                                                wp-includes/class-wp-query.php on lines 4205..4230

                                                                                Duplicated Code

                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                Tuning

                                                                                This issue has a mass of 173.

                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                Refactorings

                                                                                Further Reading

                                                                                Similar blocks of code found in 3 locations. Consider refactoring.
                                                                                Open

                                                                                    public function is_category( $category = '' ) {
                                                                                        if ( ! $this->is_category ) {
                                                                                            return false;
                                                                                        }
                                                                                
                                                                                
                                                                                Severity: Major
                                                                                Found in wp-includes/class-wp-query.php and 2 other locations - About 4 hrs to fix
                                                                                wp-includes/class-wp-query.php on lines 4127..4152
                                                                                wp-includes/class-wp-query.php on lines 4205..4230

                                                                                Duplicated Code

                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                Tuning

                                                                                This issue has a mass of 173.

                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                Refactorings

                                                                                Further Reading

                                                                                Similar blocks of code found in 3 locations. Consider refactoring.
                                                                                Open

                                                                                    public function is_tag( $tag = '' ) {
                                                                                        if ( ! $this->is_tag ) {
                                                                                            return false;
                                                                                        }
                                                                                
                                                                                
                                                                                Severity: Major
                                                                                Found in wp-includes/class-wp-query.php and 2 other locations - About 4 hrs to fix
                                                                                wp-includes/class-wp-query.php on lines 4127..4152
                                                                                wp-includes/class-wp-query.php on lines 4166..4191

                                                                                Duplicated Code

                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                Tuning

                                                                                This issue has a mass of 173.

                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                Refactorings

                                                                                Further Reading

                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                Open

                                                                                            if ( ! empty( $r_status ) ) {
                                                                                                if ( ! empty( $q['perm'] ) && 'editable' === $q['perm'] && ! current_user_can( $edit_others_cap ) ) {
                                                                                                    $statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . 'AND (' . implode( ' OR ', $r_status ) . '))';
                                                                                                } else {
                                                                                                    $statuswheres[] = '(' . implode( ' OR ', $r_status ) . ')';
                                                                                Severity: Major
                                                                                Found in wp-includes/class-wp-query.php and 1 other location - About 1 hr to fix
                                                                                wp-includes/class-wp-query.php on lines 2626..2632

                                                                                Duplicated Code

                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                Tuning

                                                                                This issue has a mass of 116.

                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                Refactorings

                                                                                Further Reading

                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                Open

                                                                                            if ( ! empty( $p_status ) ) {
                                                                                                if ( ! empty( $q['perm'] ) && 'readable' === $q['perm'] && ! current_user_can( $read_private_cap ) ) {
                                                                                                    $statuswheres[] = "({$wpdb->posts}.post_author = $user_id " . 'AND (' . implode( ' OR ', $p_status ) . '))';
                                                                                                } else {
                                                                                                    $statuswheres[] = '(' . implode( ' OR ', $p_status ) . ')';
                                                                                Severity: Major
                                                                                Found in wp-includes/class-wp-query.php and 1 other location - About 1 hr to fix
                                                                                wp-includes/class-wp-query.php on lines 2619..2625

                                                                                Duplicated Code

                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                Tuning

                                                                                This issue has a mass of 116.

                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                Refactorings

                                                                                Further Reading

                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                Open

                                                                                        if ( $q['p'] ) {
                                                                                            $where .= " AND {$wpdb->posts}.ID = " . $q['p'];
                                                                                        } elseif ( $q['post__in'] ) {
                                                                                            $post__in = implode( ',', array_map( 'absint', $q['post__in'] ) );
                                                                                            $where   .= " AND {$wpdb->posts}.ID IN ($post__in)";
                                                                                Severity: Major
                                                                                Found in wp-includes/class-wp-query.php and 1 other location - About 1 hr to fix
                                                                                wp-includes/class-wp-query.php on lines 2208..2216

                                                                                Duplicated Code

                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                Tuning

                                                                                This issue has a mass of 109.

                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                Refactorings

                                                                                Further Reading

                                                                                Similar blocks of code found in 2 locations. Consider refactoring.
                                                                                Open

                                                                                        if ( is_numeric( $q['post_parent'] ) ) {
                                                                                            $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_parent = %d ", $q['post_parent'] );
                                                                                        } elseif ( $q['post_parent__in'] ) {
                                                                                            $post_parent__in = implode( ',', array_map( 'absint', $q['post_parent__in'] ) );
                                                                                            $where          .= " AND {$wpdb->posts}.post_parent IN ($post_parent__in)";
                                                                                Severity: Major
                                                                                Found in wp-includes/class-wp-query.php and 1 other location - About 1 hr to fix
                                                                                wp-includes/class-wp-query.php on lines 2198..2206

                                                                                Duplicated Code

                                                                                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                                                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                                                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                                                Tuning

                                                                                This issue has a mass of 109.

                                                                                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                Refactorings

                                                                                Further Reading

                                                                                There are no issues that match your filters.

                                                                                Category
                                                                                Status