felixarntz/global-admin

View on GitHub
wp-global-admin/wp-admin/includes/dashboard.php

Summary

Maintainability
B
5 hrs
Test Coverage

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

    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

    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

      The function wp_global_dashboard_setup() contains an exit expression.
      Open

                  exit;

      ExitExpression

      Since: 0.2

      An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

      Example

      class Foo {
          public function bar($param)  {
              if ($param === 42) {
                  exit(23);
              }
          }
      }

      Source https://phpmd.org/rules/design.html#exitexpression

      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 $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

      All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$sentence'.
      Open

              <p class="youhave"><?php echo $sentence; ?></p>

      Detected usage of a non-validated input variable: $_SERVER
      Open

              if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) {

      Missing wp_unslash() before sanitization.
      Open

                  check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' );

      All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$actions'.
      Open

                  echo implode( " |</li>\n", $actions ) . "</li>\n";

      All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
      Open

                          <label class="screen-reader-text" for="search-networks"><?php _e( 'Search Networks', 'wp-global-admin' ); ?></label>

      All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'.
      Open

                      <label class="screen-reader-text" for="search-users"><?php _e( 'Search Users', 'wp-global-admin' ); ?></label>

      Detected usage of a non-sanitized input variable: $_POST
      Open

                  check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' );

      Inline comments must end in full-stops, exclamation marks, or question marks
      Open

                  ob_start(); // hack - but the same hack wp-admin/widgets.php uses

      All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found 'network_admin_url'.
      Open

              <form action="<?php echo network_admin_url( 'users.php' ); ?>" method="get">

      Missing wp_unslash() before sanitization.
      Open

                  wp_dashboard_trigger_widget_control( $_POST['widget_id'] );

      Detected usage of a non-sanitized input variable: $_POST
      Open

                  wp_dashboard_trigger_widget_control( $_POST['widget_id'] );

      Overriding WordPress globals is prohibited. Found assignment to $wp_dashboard_control_callbacks
      Open

              $wp_dashboard_control_callbacks = array();

      There are no issues that match your filters.

      Category
      Status