WordPress/WordPress

View on GitHub

Showing 14,522 of 14,522 total issues

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

function wp_get_theme_data_template_parts() {
    $cache_group    = 'theme_json';
    $cache_key      = 'wp_get_theme_data_template_parts';
    $can_use_cached = ! wp_is_development_mode( 'theme' );

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

    final public function check_capabilities() {
        if ( ! empty( $this->capability ) && ! current_user_can( $this->capability ) ) {
            return false;
        }
        foreach ( $this->settings as $setting_id ) {
Severity: Minor
Found in wp-includes/customize/class-wp-customize-partial.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 render_content has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function render_content() {
        if ( empty( $this->choices ) ) {
            return;
        }

Severity: Minor
Found in wp-includes/customize/class-wp-customize-nav-menu-location-control.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 match_domain has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public static function match_domain($host, $reference) {
        if (InputValidator::is_string_or_stringable($host) === false) {
            throw InvalidArgument::create(1, '$host', 'string|Stringable', gettype($host));
        }

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

    protected function get_comment( $id ) {
        $error = new WP_Error(
            'rest_comment_invalid_id',
            __( 'Invalid comment ID.' ),
            array( 'status' => 404 )
Severity: Minor
Found in wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.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_item_permissions_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_item_permissions_check( $request ) {

        $tax_obj = get_taxonomy( $request['taxonomy'] );

        if ( $tax_obj ) {
Severity: Minor
Found in wp-includes/rest-api/endpoints/class-wp-rest-taxonomies-controller.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 metadata_exists has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

function metadata_exists( $meta_type, $object_id, $meta_key ) {
    if ( ! $meta_type || ! is_numeric( $object_id ) ) {
        return false;
    }

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

    protected function normalize_query_param( $query_param ) {
        $prefix = 'comment_';

        switch ( $query_param ) {
            case 'id':
Severity: Minor
Found in wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.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 parse_url_details has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function parse_url_details( $request ) {
        $url = untrailingslashit( $request['url'] );

        if ( empty( $url ) ) {
            return new WP_Error( 'rest_invalid_url', __( 'Invalid URL' ), array( 'status' => 404 ) );
Severity: Minor
Found in wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.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 prepare_item_for_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function prepare_item_for_response( $item, $request ) {
        $fields = $this->get_fields_for_response( $request );
        $data   = array();

        if ( rest_is_field_included( 'id', $fields ) ) {
Severity: Minor
Found in wp-includes/rest-api/endpoints/class-wp-rest-font-faces-controller.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_items_permissions_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_items_permissions_check( $request ) {
        if ( 'edit' === $request['context'] ) {
            $types = get_post_types( array( 'show_in_rest' => true ), 'objects' );

            foreach ( $types as $type ) {

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 delete_item_permissions_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function delete_item_permissions_check( $request ) {
        $parent = $this->get_parent( $request['parent'] );
        if ( is_wp_error( $parent ) ) {
            return $parent;
        }
Severity: Minor
Found in wp-includes/rest-api/endpoints/class-wp-rest-revisions-controller.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_items_permissions_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_items_permissions_check( $request ) {
        $this->retrieve_widgets();
        foreach ( wp_get_sidebars_widgets() as $id => $widgets ) {
            $sidebar = $this->get_sidebar( $id );

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

    public function get_items_permissions_check( $request ) {
        if ( 'edit' === $request['context'] ) {
            $types = get_post_types( array( 'show_in_rest' => true ), 'objects' );

            foreach ( $types as $type ) {
Severity: Minor
Found in wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.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 update_item_permissions_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function update_item_permissions_check( $request ) {
        require_once ABSPATH . 'wp-admin/includes/plugin.php';

        if ( ! current_user_can( 'activate_plugins' ) ) {
            return new WP_Error(
Severity: Minor
Found in wp-includes/rest-api/endpoints/class-wp-rest-plugins-controller.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 create_item_permissions_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function create_item_permissions_check( $request ) {
        if ( ! empty( $request['id'] ) ) {
            return new WP_Error(
                'rest_post_exists',
                __( 'Cannot create existing post.' ),
Severity: Minor
Found in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.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_collection_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function get_collection_params() {
        $query_params = parent::get_collection_params();

        $query_params['context']['default'] = 'view';

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

    public function get_headers( $server ) {
        $headers = array();

        // CONTENT_* headers are not prefixed with HTTP_.
        $additional = array(
Severity: Minor
Found in wp-includes/rest-api/class-wp-rest-server.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 update_item_permissions_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function update_item_permissions_check( $request ) {
        $post = $this->get_post( $request['id'] );
        if ( is_wp_error( $post ) ) {
            return $post;
        }
Severity: Minor
Found in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.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_terms has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    protected function handle_terms( $post_id, $request ) {
        $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );

        foreach ( $taxonomies as $taxonomy ) {
            $base = ! empty( $taxonomy->rest_base ) ? $taxonomy->rest_base : $taxonomy->name;
Severity: Minor
Found in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.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