felixarntz/global-admin

View on GitHub

Showing 251 of 251 total issues

Function _ga_map_meta_cap has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

function _ga_map_meta_cap( $caps, $cap, $user_id, $args ) {
    if ( ! is_multinetwork() ) {
        return $caps;
    }

Severity: Minor
Found in wp-global-admin/wp-includes/capabilities.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 _ga_map_meta_cap has 111 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function _ga_map_meta_cap( $caps, $cap, $user_id, $args ) {
    if ( ! is_multinetwork() ) {
        return $caps;
    }

Severity: Major
Found in wp-global-admin/wp-includes/capabilities.php - About 4 hrs to fix

    Method prepare_items has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function prepare_items() {
            global $usersearch, $role, $wpdb, $mode;
    
            $usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
    
    
    Severity: Major
    Found in wp-global-admin/wp-admin/includes/class-wp-ga-users-list-table.php - About 2 hrs to fix

      Method wp_global_dashboard_right_now has 45 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function wp_global_dashboard_right_now() {
              /**
               * Filters the URL to list networks in the global Right Now dashboard widget.
               *
               * @since 1.0.0
      Severity: Minor
      Found in wp-global-admin/wp-admin/includes/dashboard.php - About 1 hr to fix

        Avoid excessively long variable names like $wp_registered_widgets. Keep variable name length under 20.
        Open

                global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#longvariable

        Avoid excessively long variable names like $wp_dashboard_control_callbacks. Keep variable name length under 20.
        Open

                global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#longvariable

        Avoid excessively long variable names like $global_administrators. Keep variable name length under 20.
        Open

                $global_administrators = get_global_option( 'global_administrators', array() );

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#longvariable

        Avoid excessively long variable names like $global_administrators. Keep variable name length under 20.
        Open

                $global_administrators = get_global_administrators();

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#longvariable

        Avoid excessively long variable names like $wp_registered_widget_controls. Keep variable name length under 20.
        Open

                global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#longvariable

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

            public function prepare_items() {
                global $usersearch, $role, $wpdb, $mode;
        
                $usersearch = isset( $_REQUEST['s'] ) ? wp_unslash( trim( $_REQUEST['s'] ) ) : '';
        
        
        Severity: Minor
        Found in wp-global-admin/wp-admin/includes/class-wp-ga-users-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 _ga_adjust_admin_bar_my_sites_menu has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function _ga_adjust_admin_bar_my_sites_menu( $admin_bar ) {
            if ( ! is_user_logged_in() || ! current_user_can( 'manage_global' ) ) {
                return;
            }
        
        
        Severity: Minor
        Found in wp-global-admin/wp-includes/admin-bar.php - About 1 hr to fix

          Function wp_global_dashboard_right_now has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              function wp_global_dashboard_right_now() {
                  /**
                   * Filters the URL to list networks in the global Right Now dashboard widget.
                   *
                   * @since 1.0.0
          Severity: Minor
          Found in wp-global-admin/wp-admin/includes/dashboard.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 wp_global_dashboard_setup has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              function wp_global_dashboard_setup() {
                  global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
          
                  $wp_dashboard_control_callbacks = array();
                  $screen                         = get_current_screen();
          Severity: Minor
          Found in wp-global-admin/wp-admin/includes/dashboard.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 _ga_maybe_modify_global_administrator_setting has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function _ga_maybe_modify_global_administrator_setting( $user_id ) {
              if ( is_multinetwork() && is_global_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_global_options' ) ) {
                  $global_administrators = get_global_option( 'global_administrators', array() );
                  $user                  = get_userdata( $user_id );
          
          
          Severity: Minor
          Found in wp-global-admin/wp-admin/global/user-edit.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 _ga_maybe_populate_global has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          function _ga_maybe_populate_global() {
              global $wpdb;
          
              if ( ! is_user_logged_in() ) {
                  return;
          Severity: Minor
          Found in wp-global-admin/wp-includes/setup.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 column_networks has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function column_networks( $user ) {
                  if ( ! function_exists( 'get_networks_of_user' ) ) {
                      return;
                  }
          
          
          Severity: Minor
          Found in wp-global-admin/wp-admin/includes/class-wp-ga-users-list-table.php - About 1 hr to fix

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

                function wp_global_dashboard_setup() {
                    global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
            
                    $wp_dashboard_control_callbacks = array();
                    $screen                         = get_current_screen();
            Severity: Minor
            Found in wp-global-admin/wp-admin/includes/dashboard.php - About 1 hr to fix

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

              function _ga_maybe_populate_global() {
                  global $wpdb;
              
                  if ( ! is_user_logged_in() ) {
                      return;
              Severity: Minor
              Found in wp-global-admin/wp-includes/setup.php - About 1 hr to fix

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

                    function global_home_url( $path = '', $scheme = null ) {
                        if ( ! is_multinetwork() ) {
                            return network_home_url( $path, $scheme );
                        }
                
                
                Severity: Minor
                Found in wp-global-admin/wp-includes/link-template.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 column_networks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                    public function column_networks( $user ) {
                        if ( ! function_exists( 'get_networks_of_user' ) ) {
                            return;
                        }
                
                
                Severity: Minor
                Found in wp-global-admin/wp-admin/includes/class-wp-ga-users-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

                Severity
                Category
                Status
                Source
                Language