WP-API/WP-API

View on GitHub

Showing 222 of 244 total issues

Avoid too many return statements within this method.
Open

                        return new WP_Error( 'rest_invalid_param', sprintf( /* translators: 1: parameter, 2: minimum number, 3: maximum number */ __( '%1$s must be between %2$d (inclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
Severity: Major
Found in plugin.php - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

            return rest_ensure_response( $response );
    Severity: Major
    Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

                          return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s must be greater than %2$d (inclusive)' ), $param, $args['minimum'] ) );
      Severity: Major
      Found in plugin.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                                return new WP_Error( 'rest_invalid_param', sprintf( /* translators: 1: parameter, 2: minimum number, 3: maximum number */ __( '%1$s must be between %2$d (exclusive) and %3$d (inclusive)' ), $param, $args['minimum'], $args['maximum'] ) );
        Severity: Major
        Found in plugin.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                          return $meta_update;
          Severity: Major
          Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return $value;
            Severity: Major
            Found in plugin.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return $response;
              Severity: Major
              Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                            return $fields_update;
                Severity: Major
                Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                  return new WP_Error( 'rest_invalid_field', __( 'A password protected post can not be set to sticky.' ), array( 'status' => 400 ) );
                  Severity: Major
                  Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return true;
                    Severity: Major
                    Found in lib/endpoints/class-wp-rest-posts-controller.php - About 30 mins to fix

                      Avoid too many return statements within this method.
                      Open

                                              return new WP_Error( 'rest_invalid_param', sprintf( __( '%s is not a valid IP address.' ), $value ) );
                      Severity: Major
                      Found in plugin.php - About 30 mins to fix

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

                            public function get_items( $request ) {
                                $data = array();
                                foreach ( get_post_types( array(), 'object' ) as $obj ) {
                                    if ( empty( $obj->show_in_rest ) || ( 'edit' === $request['context'] && ! current_user_can( $obj->cap->edit_posts ) ) ) {
                                        continue;
                        Severity: Minor
                        Found in lib/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 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 ) {
                                        if ( current_user_can( $type->cap->edit_posts ) ) {
                        Severity: Minor
                        Found in lib/endpoints/class-wp-rest-post-statuses-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_links has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function prepare_links( $comment ) {
                                $links = array(
                                    'self' => array(
                                        'href' => rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $comment->comment_ID ) ),
                                    ),
                        Severity: Minor
                        Found in lib/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 create_item_permissions_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function create_item_permissions_check( $request ) {
                                $ret = parent::create_item_permissions_check( $request );
                                if ( ! $ret || is_wp_error( $ret ) ) {
                                    return $ret;
                                }
                        Severity: Minor
                        Found in lib/endpoints/class-wp-rest-attachments-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_terms_for_post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function get_terms_for_post( $prepared_args ) {
                                $query_result = get_the_terms( $prepared_args['post'], $this->taxonomy );
                                if ( empty( $query_result ) ) {
                                    $this->total_terms = 0;
                                    return array();
                        Severity: Minor
                        Found in lib/endpoints/class-wp-rest-terms-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 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 lib/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 lib/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 get_item_permissions_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public function get_item_permissions_check( $request ) {
                        
                                $id = (int) $request['id'];
                                $user = get_userdata( $id );
                                $types = get_post_types( array( 'show_in_rest' => true ), 'names' );
                        Severity: Minor
                        Found in lib/endpoints/class-wp-rest-users-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_items_query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            protected function prepare_items_query( $prepared_args = array(), $request = null ) {
                        
                                $valid_vars = array_flip( $this->get_allowed_query_vars( $request ) );
                                $query_args = array();
                                foreach ( $valid_vars as $var => $index ) {
                        Severity: Minor
                        Found in lib/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