felixarntz/post-types-definitely

View on GitHub
inc/WPPTD/PostTypeQueryHandler.php

Summary

Maintainability
C
1 day
Test Coverage

Function maybe_filter_by_table_columns has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

        public function maybe_filter_by_table_columns( $wp_query ) {
            $table_columns = $this->component->table_columns;

            $tax_query = array();
            $meta_query = array();
Severity: Minor
Found in inc/WPPTD/PostTypeQueryHandler.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

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

        public function register_table_filter_query_vars( $vars ) {
            $table_columns = $this->component->table_columns;

            foreach ( $table_columns as $column_slug => $column_args ) {
                if ( is_array( $column_args ) && $column_args['filterable'] ) {
Severity: Minor
Found in inc/WPPTD/PostTypeQueryHandler.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 maybe_filter_by_table_columns has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public function maybe_filter_by_table_columns( $wp_query ) {
            $table_columns = $this->component->table_columns;

            $tax_query = array();
            $meta_query = array();
Severity: Minor
Found in inc/WPPTD/PostTypeQueryHandler.php - About 1 hr to fix

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

            public function maybe_sort_by_taxonomy_table_column( $clauses, $wp_query ) {
                global $wpdb;
    
                $table_columns = $this->component->table_columns;
    
    
    Severity: Minor
    Found in inc/WPPTD/PostTypeQueryHandler.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 filter_by_meta has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

            protected function filter_by_meta( $value, $column_slug, $meta_key ) {
                $meta_value = stripslashes( $value);
                if ( $meta_value ) {
                    $this->active_filters[ $column_slug ] = $meta_value;
                    if ( 'bool:true' === $meta_value ) {
    Severity: Minor
    Found in inc/WPPTD/PostTypeQueryHandler.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

    Avoid too many return statements within this method.
    Open

                return $clauses;
    Severity: Major
    Found in inc/WPPTD/PostTypeQueryHandler.php - About 30 mins to fix

      There are no issues that match your filters.

      Category
      Status