Showing 26 of 26 total issues
Function sanitize_order_by
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
function sanitize_order_by( $string ) {
if ( strtolower( trim( rtrim( $string ) ) ) === 'rand()' ) {
return 'RAND()'; }
if ( strrpos( $string, ';' ) !== false ) {
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 get_unique_items
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function get_unique_items() : array {
$unique = [];
foreach ( $this->items as $i => $item_a ) {
$duplicate = false;
- 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 to_title_case
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function to_title_case( $title ) {
$title = (string) $title;
// Our array of 'small words' which shouldn't be capitalised if
// they aren't the first word. Add your own words to taste.
$small_words = array(
Method do_route
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function do_route( $class_name, $method_name, $named_arguments, $on_error ) {
if ( \is_object( $class_name ) ) {
return $this->call(
array(
$class_name,
Function add_data
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function add_data( $data ) : View_Factory {
if ( \is_array( $data ) ) {
foreach ( $data as $key => $value ) {
$data_to_add = $value;
if ( $value instanceof Presentable_Model ) {
- 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 present
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function present( $any, array $options = [] ) {
$presented = null;
if ( is_array( $any ) ) {
$presented = [];
- 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
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function validate( $error_callback ) {
$rules = $this->validation_rules();
$results = [];
- 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
Avoid too many return
statements within this method. Open
return $value;
Avoid too many return
statements within this method. Open
return ''; }
Avoid too many return
statements within this method. Open
return $string;
Avoid too many return
statements within this method. Open
return ''; }
Avoid too many return
statements within this method. Open
return false;
Avoid too many return
statements within this method. Open
return $value_a > $value_b;
Avoid too many return
statements within this method. Open
return ''; }
Avoid too many return
statements within this method. Open
return $value_a || $value_b;
Avoid too many return
statements within this method. Open
return ''; }
Avoid too many return
statements within this method. Open
return $value_a && $value_b;
Avoid too many return
statements within this method. Open
return ''; }
Avoid too many return
statements within this method. Open
return ''; }
Avoid too many return
statements within this method. Open
return $value_a >= $value_b;