class-api.php
Function get_resource
has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring. Open
Open
public function get_resource( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
$params = $request->get_params();
$ldp_container = $params['ldp_container'];
$ldp_resource_slug = $params['ldp_resource'];
- 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_resource
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function get_resource( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
$params = $request->get_params();
$ldp_container = $params['ldp_container'];
$ldp_resource_slug = $params['ldp_resource'];
Function get_api_definition
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
Open
public function get_api_definition( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
header( 'Content-Type: application/ld+json' );
header( 'Access-Control-Allow-Origin: *' );
$query = new \WP_Query(
- 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_api_definition
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public function get_api_definition( \WP_REST_Request $request, \WP_REST_Response $response = null ) {
header( 'Content-Type: application/ld+json' );
header( 'Access-Control-Allow-Origin: *' );
$query = new \WP_Query(
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space Open
Open
$term_id = $terms[0]->term_id;
- Exclude checks
Missing wp_unslash() before sanitization. Open
Open
$referer = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : null;
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 29 spaces but found 1 space Open
Open
$current_container_entry['@id'] = site_url( '/' ) . \WpLdp\Api::LDP_API_URL . $value['id'] . '/';
- Exclude checks
Array double arrow not aligned correctly; expected 2 space(s) between "'methods'" and double arrow, but found 1. Open
Open
'methods' => \WP_REST_Server::READABLE,
- Exclude checks
Array double arrow not aligned correctly; expected 3 space(s) between "'@id'" and double arrow, but found 1. Open
Open
'@id' => rtrim( get_rest_url(), '/' ) . $request->get_route() . '/',
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 36 spaces but found 1 space Open
Open
$current_container_entry = array();
- Exclude checks
Array double arrow not aligned correctly; expected 1 space(s) between "'@id'" and double arrow, but found 2. Open
Open
'@id' => ! empty( $value ) ? $value : null,
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space Open
Open
$current_post_entry['@id'] = get_permalink( $post->ID );
- Exclude checks
Array double arrow not aligned correctly; expected 6 space(s) between "'post_type'" and double arrow, but found 1. Open
Open
'post_type' => 'ldp_resource',
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 26 spaces but found 1 space Open
Open
$current_container_entry['@count'] = $value['value'];
- Exclude checks
Array double arrow not aligned correctly; expected 8 space(s) between "'orderby'" and double arrow, but found 1. Open
Open
'orderby' => 'menu_order',
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 23 spaces but found 1 space Open
Open
$field_values = get_post_custom_values( $field_name, $post->ID )[0];
- Exclude checks
Array double arrow not aligned correctly; expected 9 space(s) between "'author'" and double arrow, but found 1. Open
Open
'author' => $user->data->ID,
- Exclude checks
Array double arrow not aligned correctly; expected 6 space(s) between "'post_type'" and double arrow, but found 1. Open
Open
'post_type' => 'post',
- Exclude checks
Each array item in a multi-line array declaration must end in a comma Open
Open
)
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space Open
Open
$rdf_type = isset( $term_meta['ldp_rdf_type'] ) ? $term_meta['ldp_rdf_type'] : null;
- Exclude checks
Array double arrow not aligned correctly; expected 6 space(s) between "'name'" and double arrow, but found 1. Open
Open
'name' => $ldp_resource_slug,
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 24 spaces but found 1 space Open
Open
$field_value = get_post_custom_values( $field_name, $post->ID )[0];
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space Open
Open
$array[ $rdf_type ]['id'] = strtolower( explode( ':', $rdf_type )[1] );
- Exclude checks
Array double arrow not aligned correctly; expected 4 space(s) between "'post_status'" and double arrow, but found 1. Open
Open
'post_status' => 'any',
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space Open
Open
$ldp_container = $params['ldp_container'];
- Exclude checks
unserialize() found. Serialized data has known vulnerability problems with Object Injection. JSON is generally a better approach for serializing data. See https://www.owasp.org/index.php/PHP_Object_Injection Open
Open
$field_values = unserialize( $field_values );
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space Open
Open
$rdf_type = isset( $term_meta['ldp_rdf_type'] ) ? $term_meta['ldp_rdf_type'] : null;
- Exclude checks
Array double arrow not aligned correctly; expected 2 space(s) between "'methods'" and double arrow, but found 1. Open
Open
'methods' => \WP_REST_Server::READABLE,
- Exclude checks
Detected usage of a non-sanitized input variable: $_SERVER Open
Open
$referer = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : null;
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 27 spaces but found 1 space Open
Open
$current_container_entry['@type'] = 'http://www.w3.org/ns/ldp#BasicContainer';
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 12 spaces but found 1 space Open
Open
$params = $request->get_params();
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 13 spaces but found 1 space Open
Open
$current_post_entry = array();
- Exclude checks
Must use "self::" for local static member reference Open
Open
$current_container_entry['@id'] = site_url( '/' ) . \WpLdp\Api::LDP_API_URL . $value['id'] . '/';
- Exclude checks
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space Open
Open
$terms = wp_get_post_terms( $post->ID, 'ldp_container' );
- Exclude checks
No space found after comma in function call Open
Open
if ( array_key_exists( $rdf_type,$array ) ) {
- Exclude checks