felixarntz/post-types-definitely

View on GitHub
inc/WPPTD/PostTypeTableHandler.php

Summary

Maintainability
D
2 days
Test Coverage

Function validate_args has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
Open

        public static function validate_args( $args ) {
            // handle admin table columns
            if ( ! $args['show_ui'] || ! is_array( $args['table_columns'] ) ) {
                $args['table_columns'] = array();
            }
Severity: Minor
Found in inc/WPPTD/PostTypeTableHandler.php - About 6 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 get_table_taxonomies has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

        public function get_table_taxonomies( $taxonomies ) {
            $table_columns = $this->component->table_columns;

            foreach ( $table_columns as $column_slug => $column_args ) {
                if ( $column_args && ! empty( $column_args['taxonomy_slug'] ) && is_object_in_taxonomy( $this->component->slug, $column_args['taxonomy_slug'] ) ) {
Severity: Minor
Found in inc/WPPTD/PostTypeTableHandler.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 render_table_column_filters has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

        public function render_table_column_filters() {
            $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/PostTypeTableHandler.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 render_meta_column_choice_filter has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

        protected function render_meta_column_choice_filter( $column_slug, $field, $active_filters ) {
            echo '<select name="' . $column_slug . '" id="' . $column_slug . '" class="postform">';
            echo '<option value="">' . esc_html( $field->title ) . ': ' . __( 'All', 'post-types-definitely' ) . '</option>';
            foreach ( $field->options as $value => $label ) {
                echo '<option value="' . esc_attr( $value ) . '"' . ( ( isset( $active_filters[ $column_slug ] ) && $active_filters[ $column_slug ] == $value ) ? ' selected="selected"' : '' ) . '>';
Severity: Minor
Found in inc/WPPTD/PostTypeTableHandler.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 validate_args has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        public static function validate_args( $args ) {
            // handle admin table columns
            if ( ! $args['show_ui'] || ! is_array( $args['table_columns'] ) ) {
                $args['table_columns'] = array();
            }
Severity: Minor
Found in inc/WPPTD/PostTypeTableHandler.php - About 1 hr to fix

    Function filter_table_sortable_column has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            protected function filter_table_sortable_column( $slug, $args ) {
                if ( ! is_array( $args ) ) {
                    return false;
                }
    
    
    Severity: Minor
    Found in inc/WPPTD/PostTypeTableHandler.php - About 45 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 deeply nested control flow statements.
    Open

                                if ( $taxonomy ) {
                                    $this->render_taxonomy_column_filter( $column_slug, $taxonomy );
                                }
    Severity: Major
    Found in inc/WPPTD/PostTypeTableHandler.php - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                                  if ( false !== ( $key = array_search( $column_key, $taxonomies ) ) ) {
                                      unset( $taxonomies[ $key ] );
                                  }
      Severity: Major
      Found in inc/WPPTD/PostTypeTableHandler.php - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                    if ( 'category' === $taxonomy_slug ) {
                                        $column_key = 'categories';
                                    } elseif ( 'post_tag' === $taxonomy_slug || 'tag' === $taxonomy_slug ) {
                                        $column_key = 'tags';
                                    }
        Severity: Major
        Found in inc/WPPTD/PostTypeTableHandler.php - About 45 mins to fix

          Consider simplifying this complex logical expression.
          Open

          if ( ! class_exists( 'WPPTD\PostTypeTableHandler' ) ) {
              /**
               * This class handles the post list table for a post type registered with WPPTD.
               *
               * @internal
          Severity: Major
          Found in inc/WPPTD/PostTypeTableHandler.php - About 40 mins to fix

            There are no issues that match your filters.

            Category
            Status