WP-API/WP-API

View on GitHub

Showing 244 of 244 total issues

Avoid too many return statements within this method.
Open

                    return sanitize_text_field( $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 $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_date', __( 'The date you provided is invalid.' ) );
        Severity: Major
        Found in plugin.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                              return esc_url_raw( $value );
          Severity: Major
          Found in plugin.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( __( '%1$s must be greater than %2$d (exclusive)' ), $param, $args['minimum'] ) );
              Severity: Major
              Found in plugin.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                    return sanitize_text_field( $value );
                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( __( '%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( __( '%1$s must be less than %2$d (exclusive)' ), $param, $args['maximum'] ) );
                    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 (inclusive) and %3$d (exclusive)' ), $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 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 true;
                          Severity: Major
                          Found in plugin.php - About 30 mins to fix

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

                            Severity
                            Category
                            Status
                            Source
                            Language