classes/class-list-table.php

Summary

Maintainability
F
1 wk
Test Coverage
C
79%

File class-list-table.php has 776 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * Generates a filterable list of provided records to be displayed HTML Table.
 *
 * @package WP_Stream
Severity: Major
Found in classes/class-list-table.php - About 1 day to fix

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

        public function filters_form() {
            $filters = $this->get_filters();
    
            $filters_string  = sprintf( '<input type="hidden" name="page" value="%s" />', 'wp_stream' );
            $filters_string .= sprintf( '<span class="filter_info hidden">%s</span>', esc_html__( 'Show filter controls via the screen options tab above.', 'stream' ) );
    Severity: Minor
    Found in classes/class-list-table.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

    Method column_default has 91 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function column_default( $item, $column_name ) {
            $out    = '';
            $record = new Record( $item );
    
            switch ( $column_name ) {
    Severity: Major
    Found in classes/class-list-table.php - About 3 hrs to fix

      List_Table has 29 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class List_Table extends \WP_List_Table {
      
          /**
           * Holds Instance of plugin object
           *
      Severity: Minor
      Found in classes/class-list-table.php - About 3 hrs to fix

        Method assemble_records has 79 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function assemble_records( $column ) {
                // @todo eliminate special condition for authors, especially using a WP_User object as the value; should use string or stringifiable object
                if ( 'user_id' === $column ) {
                    $all_records = array();
        
        
        Severity: Major
        Found in classes/class-list-table.php - About 3 hrs to fix

          Method filters_form has 66 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function filters_form() {
                  $filters = $this->get_filters();
          
                  $filters_string  = sprintf( '<input type="hidden" name="page" value="%s" />', 'wp_stream' );
                  $filters_string .= sprintf( '<span class="filter_info hidden">%s</span>', esc_html__( 'Show filter controls via the screen options tab above.', 'stream' ) );
          Severity: Major
          Found in classes/class-list-table.php - About 2 hrs to fix

            Function assemble_records has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                public function assemble_records( $column ) {
                    // @todo eliminate special condition for authors, especially using a WP_User object as the value; should use string or stringifiable object
                    if ( 'user_id' === $column ) {
                        $all_records = array();
            
            
            Severity: Minor
            Found in classes/class-list-table.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 get_records has 60 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function get_records() {
                    $args = array();
            
                    // Parse sorting params.
                    $order = wp_stream_filter_input( INPUT_GET, 'order' );
            Severity: Major
            Found in classes/class-list-table.php - About 2 hrs to fix

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

                  public function column_default( $item, $column_name ) {
                      $out    = '';
                      $record = new Record( $item );
              
                      switch ( $column_name ) {
              Severity: Minor
              Found in classes/class-list-table.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 get_records has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function get_records() {
                      $args = array();
              
                      // Parse sorting params.
                      $order = wp_stream_filter_input( INPUT_GET, 'order' );
              Severity: Minor
              Found in classes/class-list-table.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 filter_date has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function filter_date( $items ) {
                      wp_enqueue_style( 'jquery-ui' );
                      wp_enqueue_style( 'wp-stream-datepicker' );
                      wp_enqueue_script( 'jquery-ui-datepicker' );
              
              
              Severity: Minor
              Found in classes/class-list-table.php - About 1 hr to fix

                Method filter_select has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function filter_select( $name, $title, $items, $ajax = false ) {
                        $options  = array( '<option value=""></option>' );
                        $selected = wp_stream_filter_input( INPUT_GET, $name );
                
                        foreach ( $items as $key => $item ) {
                Severity: Minor
                Found in classes/class-list-table.php - About 1 hr to fix

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

                      public function __construct( $plugin, $args = array() ) {
                          $this->plugin = $plugin;
                  
                          $screen_id = isset( $args['screen'] ) ? $args['screen'] : null;
                  
                  
                  Severity: Minor
                  Found in classes/class-list-table.php - About 1 hr to fix

                    Function get_action_links has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        public function get_action_links( $record ) {
                            $out = '';
                    
                            /**
                             * Filter allows modification of action links for a specific connector
                    Severity: Minor
                    Found in classes/class-list-table.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 screen_controls has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function screen_controls( $status, $args ) {
                            unset( $status );
                            unset( $args );
                    
                            $user_id   = get_current_user_id();
                    Severity: Minor
                    Found in classes/class-list-table.php - About 1 hr to fix

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

                          public function record_actions_form() {
                              /**
                               * Filter the records screen actions dropdown menu
                               *
                               * @return array Should be in the format of action_slug => 'Action Name'
                      Severity: Minor
                      Found in classes/class-list-table.php - About 1 hr to fix

                        Method get_action_links has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            public function get_action_links( $record ) {
                                $out = '';
                        
                                /**
                                 * Filter allows modification of action links for a specific connector
                        Severity: Minor
                        Found in classes/class-list-table.php - About 1 hr to fix

                          Avoid too many return statements within this method.
                          Open

                                          return 0;
                          Severity: Major
                          Found in classes/class-list-table.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return ( strtolower( $label_a ) < strtolower( $label_b ) ) ? - 1 : 1;
                            Severity: Major
                            Found in classes/class-list-table.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                      return $all_records;
                              Severity: Major
                              Found in classes/class-list-table.php - About 30 mins to fix

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

                                    public function get_column_excluded_setting_key( $column ) {
                                        switch ( $column ) {
                                            case 'connector':
                                                $output = 'connectors';
                                                break;
                                Severity: Minor
                                Found in classes/class-list-table.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 filter_select has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    public function filter_select( $name, $title, $items, $ajax = false ) {
                                        $options  = array( '<option value=""></option>' );
                                        $selected = wp_stream_filter_input( INPUT_GET, $name );
                                
                                        foreach ( $items as $key => $item ) {
                                Severity: Minor
                                Found in classes/class-list-table.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

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

                                            if ( is_multisite() && is_super_admin() ) {
                                                $super_admins = array_map(
                                                    function ( $login ) {
                                                        $user = get_user_by( 'login', $login );
                                
                                
                                Severity: Minor
                                Found in classes/class-list-table.php and 1 other location - About 55 mins to fix
                                alerts/class-alert-trigger-author.php on lines 105..115

                                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 99.

                                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

                                            array(
                                                'date'    => __( 'Date', 'stream' ),
                                                'summary' => __( 'Summary', 'stream' ),
                                                'user_id' => __( 'User', 'stream' ),
                                                'context' => __( 'Context', 'stream' ),
                                Severity: Minor
                                Found in classes/class-list-table.php and 1 other location - About 35 mins to fix
                                connectors/class-connector-media.php on lines 49..56

                                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 92.

                                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