WordPress/WordPress

View on GitHub

Showing 10,370 of 14,330 total issues

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

function register_widget_control($name, $control_callback, $width = '', $height = '', ...$params) {
    _deprecated_function( __FUNCTION__, '2.8.0', 'wp_register_widget_control()' );
    // Compat.
    if ( is_array( $name ) ) {
        if ( count( $name ) === 3 ) {
Severity: Minor
Found in wp-includes/deprecated.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 _wp_privacy_send_request_confirmation_notification has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function _wp_privacy_send_request_confirmation_notification( $request_id ) {
    $request = wp_get_user_request( $request_id );

    if ( ! ( $request instanceof WP_User_Request ) || 'request-confirmed' !== $request->status ) {
        return;
Severity: Minor
Found in wp-includes/user.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 wp_targeted_link_rel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function wp_targeted_link_rel( $text ) {
    // Don't run (more expensive) regex if no links with targets.
    if ( stripos( $text, 'target' ) === false || stripos( $text, '<a ' ) === false || is_serialized( $text ) ) {
        return $text;
    }
Severity: Minor
Found in wp-includes/formatting.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 _remove_theme_attribute_in_block_template_content has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function _remove_theme_attribute_in_block_template_content( $template_content ) {
    _deprecated_function(
        __FUNCTION__,
        '6.4.0',
        'traverse_and_serialize_blocks( parse_blocks( $template_content ), "_remove_theme_attribute_from_template_part_block" )'
Severity: Minor
Found in wp-includes/deprecated.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 _sanitize_text_fields has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function _sanitize_text_fields( $str, $keep_newlines = false ) {
    if ( is_object( $str ) || is_array( $str ) ) {
        return '';
    }

Severity: Minor
Found in wp-includes/formatting.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 wp_trim_words has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function wp_trim_words( $text, $num_words = 55, $more = null ) {
    if ( null === $more ) {
        $more = __( '&hellip;' );
    }

Severity: Minor
Found in wp-includes/formatting.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 is_site_admin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function is_site_admin( $user_login = '' ) {
    _deprecated_function( __FUNCTION__, '3.0.0', 'is_super_admin()' );

    if ( empty( $user_login ) ) {
        $user_id = get_current_user_id();
Severity: Minor
Found in wp-includes/ms-deprecated.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 handle_begin_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function handle_begin_link( $ttl ) {
        if ( ! isset( $GLOBALS['pagenow'] ) || 'wp-login.php' !== $GLOBALS['pagenow'] ) {
            return;
        }

Severity: Minor
Found in wp-includes/class-wp-recovery-mode-link-service.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 available_items_template has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function available_items_template() {
        ?>
        <div id="available-menu-items" class="accordion-container">
            <div class="customize-section-title">
                <button type="button" class="customize-section-back" tabindex="-1">
Severity: Minor
Found in wp-includes/class-wp-customize-nav-menus.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 rest_find_any_matching_schema has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function rest_find_any_matching_schema( $value, $args, $param ) {
    $errors = array();

    foreach ( $args['anyOf'] as $index => $schema ) {
        if ( ! isset( $schema['type'] ) && isset( $args['type'] ) ) {
Severity: Minor
Found in wp-includes/rest-api.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 maybe_send_recovery_mode_email has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function maybe_send_recovery_mode_email( $rate_limit, $error, $extension ) {

        $last_sent = get_option( self::RATE_LIMIT_OPTION );

        if ( ! $last_sent || time() > $last_sent + $rate_limit ) {
Severity: Minor
Found in wp-includes/class-wp-recovery-mode-email-service.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 rest_validate_enum has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function rest_validate_enum( $value, $args, $param ) {
    $sanitized_value = rest_sanitize_value_from_schema( $value, $args, $param );
    if ( is_wp_error( $sanitized_value ) ) {
        return $sanitized_value;
    }
Severity: Minor
Found in wp-includes/rest-api.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 rest_is_field_included has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function rest_is_field_included( $field, $fields ) {
    if ( in_array( $field, $fields, true ) ) {
        return true;
    }

Severity: Minor
Found in wp-includes/rest-api.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 register has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function register( $name, $args = array() ) {
        $block_type = null;
        if ( $name instanceof WP_Block_Type ) {
            $block_type = $name;
            $name       = $block_type->name;
Severity: Minor
Found in wp-includes/class-wp-block-type-registry.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 rest_find_matching_pattern_property_schema has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function rest_find_matching_pattern_property_schema( $property, $args ) {
    if ( isset( $args['patternProperties'] ) ) {
        foreach ( $args['patternProperties'] as $pattern => $child_schema ) {
            if ( rest_validate_json_schema_pattern( $pattern, $property ) ) {
                return $child_schema;
Severity: Minor
Found in wp-includes/rest-api.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 get_posts_nav_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function get_posts_nav_link( $args = array() ) {
    global $wp_query;

    $return = '';

Severity: Minor
Found in wp-includes/link-template.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 get_edit_user_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function get_edit_user_link( $user_id = null ) {
    if ( ! $user_id ) {
        $user_id = get_current_user_id();
    }

Severity: Minor
Found in wp-includes/link-template.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 get_next_posts_page_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function get_next_posts_page_link( $max_page = 0 ) {
    global $paged;

    if ( ! is_single() ) {
        if ( ! $paged ) {
Severity: Minor
Found in wp-includes/link-template.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 get_next_comments_link has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function get_next_comments_link( $label = '', $max_page = 0 ) {
    global $wp_query;

    if ( ! is_singular() ) {
        return;
Severity: Minor
Found in wp-includes/link-template.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 paginate_comments_links has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function paginate_comments_links( $args = array() ) {
    global $wp_rewrite;

    if ( ! is_singular() ) {
        return;
Severity: Minor
Found in wp-includes/link-template.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

Severity
Category
Status
Source
Language