File models-list-table.php
has 495 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* List table class
*
* @package Leaves_And_Love\Plugin_Lib
Function build_views
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
protected function build_views( &$current, $list_url = '' ) {
$capabilities = $this->manager->capabilities();
$current = 'all';
$total = 0;
- 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 build_query_params
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
protected function build_query_params( $number, $offset ) {
$query_params = array(
'number' => $number,
'offset' => $offset,
);
- 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 build_row_actions
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
protected function build_row_actions( $model, $model_id, $view_url = '', $edit_url = '', $list_url = '' ) {
$actions = array();
$title = null;
if ( method_exists( $this->manager, 'get_title_property' ) ) {
- 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
The class Models_List_Table has an overall complexity of 137 which is very high. The configured complexity threshold is 50. Open
abstract class Models_List_Table extends \WP_List_Table {
/**
* The manager instance.
*
* @since 1.0.0
- Exclude checks
Function months_dropdown
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
protected function months_dropdown( $date_property ) {
global $wp_locale;
$where = '';
$where_args = array();
- 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 build_query_params
has 72 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function build_query_params( $number, $offset ) {
$query_params = array(
'number' => $number,
'offset' => $offset,
);
Models_List_Table
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
abstract class Models_List_Table extends \WP_List_Table {
/**
* The manager instance.
*
* @since 1.0.0
Method build_views
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function build_views( &$current, $list_url = '' ) {
$capabilities = $this->manager->capabilities();
$current = 'all';
$total = 0;
Method build_row_actions
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function build_row_actions( $model, $model_id, $view_url = '', $edit_url = '', $list_url = '' ) {
$actions = array();
$title = null;
if ( method_exists( $this->manager, 'get_title_property' ) ) {
Function column_default
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
public function column_default( $model, $column_name ) {
if ( has_action( "{$this->_args['plural']}_list_table_column_{$column_name}" ) ) {
/**
* Fires when a column without a specific callback should be rendered.
*
- 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 __construct
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function __construct( $manager, $args = array() ) {
$this->manager = $manager;
if ( empty( $args['singular'] ) ) {
$args['singular'] = $this->manager->get_prefix() . $this->manager->get_singular_slug();
- 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 months_dropdown
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function months_dropdown( $date_property ) {
global $wp_locale;
$where = '';
$where_args = array();
Method handle_row_actions
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
protected function handle_row_actions( $model, $column_name, $primary ) {
if ( $column_name !== $primary ) {
return '';
}
Function get_views
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
protected function get_views() {
$current = '';
$views = $this->build_views( $current, $this->_args['models_page'] );
- 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 handle_row_actions
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
protected function handle_row_actions( $model, $column_name, $primary ) {
if ( $column_name !== $primary ) {
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
Method build_row_actions
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
protected function build_row_actions( $model, $model_id, $view_url = '', $edit_url = '', $list_url = '' ) {
Function build_columns
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
protected function build_columns() {
$columns = array();
$columns['cb'] = '<input type="checkbox" />';
if ( method_exists( $this->manager, 'get_title_property' ) ) {
- 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
The method build_query_params() has an NPath complexity of 12600. The configured NPath complexity threshold is 200. Open
protected function build_query_params( $number, $offset ) {
$query_params = array(
'number' => $number,
'offset' => $offset,
);
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method build_row_actions() has an NPath complexity of 352. The configured NPath complexity threshold is 200. Open
protected function build_row_actions( $model, $model_id, $view_url = '', $edit_url = '', $list_url = '' ) {
$actions = array();
$title = null;
if ( method_exists( $this->manager, 'get_title_property' ) ) {
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method months_dropdown() has an NPath complexity of 288. The configured NPath complexity threshold is 200. Open
protected function months_dropdown( $date_property ) {
global $wp_locale;
$where = '';
$where_args = array();
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method build_query_params() has 102 lines of code. Current threshold is set to 100. Avoid really long methods. Open
protected function build_query_params( $number, $offset ) {
$query_params = array(
'number' => $number,
'offset' => $offset,
);
- Exclude checks
The method build_views() has an NPath complexity of 2088. The configured NPath complexity threshold is 200. Open
protected function build_views( &$current, $list_url = '' ) {
$capabilities = $this->manager->capabilities();
$current = 'all';
$total = 0;
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method build_query_params() has a Cyclomatic Complexity of 21. The configured cyclomatic complexity threshold is 10. Open
protected function build_query_params( $number, $offset ) {
$query_params = array(
'number' => $number,
'offset' => $offset,
);
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method months_dropdown() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
protected function months_dropdown( $date_property ) {
global $wp_locale;
$where = '';
$where_args = array();
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method column_default() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10. Open
public function column_default( $model, $column_name ) {
if ( has_action( "{$this->_args['plural']}_list_table_column_{$column_name}" ) ) {
/**
* Fires when a column without a specific callback should be rendered.
*
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method build_row_actions() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10. Open
protected function build_row_actions( $model, $model_id, $view_url = '', $edit_url = '', $list_url = '' ) {
$actions = array();
$title = null;
if ( method_exists( $this->manager, 'get_title_property' ) ) {
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The method build_views() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10. Open
protected function build_views( &$current, $list_url = '' ) {
$capabilities = $this->manager->capabilities();
$current = 'all';
$total = 0;
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Avoid using static access to class '\Leaves_And_Love\Plugin_Lib\Fixes' in method 'handle_row_actions'. Open
'_wp_http_referer' => rawurlencode( Fixes::php_filter_input( INPUT_SERVER, 'REQUEST_URI' ) ),
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid unused parameters such as '$list_url'. Open
protected function build_row_actions( $model, $model_id, $view_url = '', $edit_url = '', $list_url = '' ) {
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid variables with short names like $m. Configured minimum length is 3. Open
$m = filter_input( INPUT_GET, 'm', FILTER_SANITIZE_NUMBER_INT );
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}