wp-global-admin/wp-admin/global/user-edit.php
Function _ga_maybe_modify_global_administrator_setting
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
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 );
- Read upRead up
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_display_global_administrator_checkbox
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
function _ga_maybe_display_global_administrator_checkbox( $user ) {
if ( is_multinetwork() && is_global_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_global_options' ) ) {
?>
</table>
- Read upRead up
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 excessively long variable names like $global_administrators. Keep variable name length under 20. Open
Open
$global_administrators = get_global_option( 'global_administrators', array() );
- Read upRead up
- Exclude checks
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 (like esc_html_e() or esc_attr_e()), found '_e'. Open
Open
<p><?php _e( 'Global administrator privileges cannot be removed because this user has the global admin email.', 'wp-global-admin' ); ?></p>
- Exclude checks
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'. Open
Open
<p><label><input type="checkbox" id="global_administrator" name="global_administrator"<?php checked( is_global_administrator( $user->ID ) ); ?> /> <?php _e( 'Grant this user global administrator privileges.', 'wp-global-admin' ); ?></label></p>
- Exclude checks
All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '__'. Open
Open
wp_die( __( 'Multinetwork support is not enabled.', 'wp-global-admin' ) );
- Exclude checks
Use Yoda Condition checks, you must. Open
Open
<?php if ( $user->user_email != get_global_option( 'admin_email' ) || ! is_global_administrator( $user->ID ) ) : ?>
- Exclude checks
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'. Open
Open
<?php _e( 'Global Administrator', 'wp-global-admin' ); ?>
- Exclude checks
All output should be run through an escaping function (like esc_html_e() or esc_attr_e()), found '_e'. Open
Open
<h2><?php _e( 'Permissions', 'wp-global-admin' ); ?></h2>
- Exclude checks
Processing form data without nonce verification. Open
Open
if ( ! empty( $_POST['global_administrator'] ) ) {
- Exclude checks