Showing 222 of 244 total issues
File class-wp-rest-posts-controller.php
has 1318 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
class WP_REST_Posts_Controller extends WP_REST_Controller {
/**
File class-wp-rest-comments-controller.php
has 928 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Access comments
*/
Function rest_validate_request_arg
has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring. Open
function rest_validate_request_arg( $value, $request, $param ) {
$attributes = $request->get_attributes();
if ( ! isset( $attributes['args'][ $param ] ) || ! is_array( $attributes['args'][ $param ] ) ) {
return true;
- 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
File wp-api.js
has 710 lines of code (exceeds 250 allowed). Consider refactoring. Open
(function( window, undefined ) {
'use strict';
/**
File class-wp-rest-users-controller.php
has 677 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Access users
*/
Method get_item_schema
has 299 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_item_schema() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => $this->post_type,
File class-wp-rest-terms-controller.php
has 586 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Access terms associated with a taxonomy.
*/
Function addMixinsAndHelpers
has 208 lines of code (exceeds 25 allowed). Consider refactoring. Open
wp.api.utils.addMixinsAndHelpers = function( model, modelClassName, loadingObjects ) {
var hasDate = false,
/**
Function prepare_item_for_database
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
protected function prepare_item_for_database( $request ) {
$prepared_post = new stdClass;
// ID.
if ( isset( $request['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
Method get_item_schema
has 148 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_item_schema() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'comment',
'type' => 'object',
Method get_item_schema
has 141 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_item_schema() {
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'user',
'type' => 'object',
File plugin.php
has 400 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Plugin Name: WP REST API
* Description: JSON-based REST API for WordPress, originally developed as part of GSoC 2013.
* Author: WP REST API Team
Function constructFromSchema
has 139 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructFromSchema: function() {
var routeModel = this, modelRoutes, collectionRoutes, schemaRoot, loadingObjects,
/**
* Set up the model and collection name mapping options. As the schema is built, the
Function prepare_item_for_response
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
public function prepare_item_for_response( $post, $request ) {
$GLOBALS['post'] = $post;
setup_postdata( $post );
$schema = $this->get_item_schema();
- 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
Method get_collection_params
has 127 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_collection_params() {
$params = parent::get_collection_params();
$params['context']['default'] = 'view';
File class-wp-rest-attachments-controller.php
has 375 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
/**
Method get_items
has 123 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_items( $request ) {
// Make sure a search string is set in case the orderby is set to 'relevance'.
if ( ! empty( $request['orderby'] ) && 'relevance' === $request['orderby'] && empty( $request['search'] ) && empty( $request['filter']['s'] ) ) {
return new WP_Error( 'rest_no_search_term_defined', __( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) );
Function get_items
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
public function get_items( $request ) {
// Make sure a search string is set in case the orderby is set to 'relevance'.
if ( ! empty( $request['orderby'] ) && 'relevance' === $request['orderby'] && empty( $request['search'] ) && empty( $request['filter']['s'] ) ) {
return new WP_Error( 'rest_no_search_term_defined', __( 'You need to define a search term to order by relevance.' ), array( 'status' => 400 ) );
- 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
Method prepare_item_for_response
has 122 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function prepare_item_for_response( $post, $request ) {
$GLOBALS['post'] = $post;
setup_postdata( $post );
$schema = $this->get_item_schema();
Method get_collection_params
has 116 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_collection_params() {
$query_params = parent::get_collection_params();
$query_params['context']['default'] = 'view';