Function get_related_objects
has a Cognitive Complexity of 92 (exceeds 5 allowed). Consider refactoring. Open
public static function get_related_objects( $mode, $id, $objects_mode, $meta_key = '', $object_type = '', $single = false ) {
// specify variables depending on the base mode
switch ( $mode ) {
case 'post':
$get_func = 'get_post';
- 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_related_objects
has 137 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function get_related_objects( $mode, $id, $objects_mode, $meta_key = '', $object_type = '', $single = false ) {
// specify variables depending on the base mode
switch ( $mode ) {
case 'post':
$get_func = 'get_post';
Function validate_labels
has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring. Open
public static function validate_labels( $args, $key, $mode ) {
if ( false === $args[ $key ] ) {
$args[ $key ] = array();
return $args;
}
- 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 Utility.php
has 333 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* @package WPPTD
* @version 0.6.4
* @author Felix Arntz <felix-arntz@leaves-and-love.net>
Function maybe_register_related_objects_field
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public static function maybe_register_related_objects_field( $object, $args, $component, $component_parent ) {
if ( ! isset( $args['options'] ) || ! is_array( $args['options'] ) || 1 !== count( $args['options'] ) ) {
return;
}
- 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
Function parse_meta_value
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public static function parse_meta_value( $meta_value, $field, $single = null, $formatted = false ) {
$_meta_value = $meta_value;
$meta_value = null;
$type_hint = $field->validate_meta_value( null, 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
Method validate_labels
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function validate_labels( $args, $key, $mode ) {
if ( false === $args[ $key ] ) {
$args[ $key ] = array();
return $args;
}
Function validate_titles
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function validate_titles( $args, $slug, $mode ) {
if ( empty( $args['title'] ) && isset( $args['label'] ) ) {
$args['title'] = $args['label'];
unset( $args['label'] );
}
- 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 maybe_register_related_objects_field
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function maybe_register_related_objects_field( $object, $args, $component, $component_parent ) {
if ( ! isset( $args['options'] ) || ! is_array( $args['options'] ) || 1 !== count( $args['options'] ) ) {
return;
}
Function validate_help_args
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public static function validate_help_args( $args, $key ) {
if( ! is_array( $args[ $key ] ) ) {
$args[ $key ] = array();
}
if ( ! isset( $args[ $key ]['tabs'] ) || ! is_array( $args[ $key ]['tabs'] ) ) {
- 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_related_objects
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
public static function get_related_objects( $mode, $id, $objects_mode, $meta_key = '', $object_type = '', $single = false ) {
Avoid too many return
statements within this method. Open
return array();
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return array();
Avoid too many return
statements within this method. Open
return array();
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return $objects[0];
Avoid too many return
statements within this method. Open
return array();
Avoid too many return
statements within this method. Open
return $objects;
Avoid too many return
statements within this method. Open
return array();
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return null;
Avoid too many return
statements within this method. Open
return array();
Avoid too many return
statements within this method. Open
return null;
Function get_default_formatted
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function get_default_formatted( $type ) {
$formatted = true;
switch ( $type ) {
case 'checkbox':
- 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
Function validate_ui_args
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public static function validate_ui_args( $args ) {
if ( null === $args['show_ui'] ) {
$args['show_ui'] = $args['public'];
}
if ( null === $args['show_in_menu'] ) {
- 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"