Showing 114 of 114 total issues
File font-awesome-icons.php
has 789 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* Font Awesome 4.7 icons array
* http://fontawesome.io/cheatsheet/
*
Method __construct
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(array $atts ) {
/**
* Supported fields and their PHP classes
*/
Function form
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
public function form( $instance ) {
// Widget admin form fields configuration array
if ( ! is_array( $this->form_fields ) || empty( $this->form_fields ) ) {
return 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 form
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function form( $instance ) {
// Widget admin form fields configuration array
if ( ! is_array( $this->form_fields ) || empty( $this->form_fields ) ) {
return false;
Function update
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function update( $new_instance, $old_instance ) {
if ( ! is_array( $this->form_fields ) || empty( $this->form_fields ) ) {
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 field
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function field() {
$html = '';
if ( empty( $this->name ) ) {
Method validate_allowed_html_tags
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function validate_allowed_html_tags( $content ) {
global $allowedposttags;
$tags = array(
Avoid using undefined variables such as '$errors' which will lead to PHP notices. Open
$errors[] = trigger_error(
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Method field
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function field() {
$html = '';
if ( empty( $this->name ) ) {
Function field
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
public function field() {
$html = '';
if ( empty( $this->name ) ) {
- 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 field
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function field() {
$html = '';
if ( empty( $this->name ) ) {
Function field
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function field() {
$html = '';
if ( empty( $this->name ) ) {
- 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 fields_admin_scripts
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function fields_admin_scripts() {
$method = 'admin_scripts';
foreach ( $this->field_php_classes as $class ) {
- 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
Missing class import via use statement (line '153', column '17'). Open
new Predic_Widget_Builder( $atts );
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Missing class import via use statement (line '23', column '29'). Open
$this->widget = new Predic_Widget_Factory( $atts );
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
The method field uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$html .= 'data-alpha="false" ';
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method form uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$errors[] = trigger_error(
esc_attr( sprintf( __( '%s class must extend abstract class Predic_Widget_Form_Field' ), get_class( $form_field ) ) ),
E_USER_ERROR
);
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method fields_admin_scripts uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
trigger_error( strip_tags( sprintf( __( 'File %s does not exists.', 'predic_widget' ), $class['path'] ) ), E_USER_WARNING );
continue;
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method form() has an NPath complexity of 3459. The configured NPath complexity threshold is 200. Open
public function form( $instance ) {
// Widget admin form fields configuration array
if ( ! is_array( $this->form_fields ) || empty( $this->form_fields ) ) {
return false;
- 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
Avoid unused private methods such as '__wakeup'. Open
private function __wakeup() {
}
- Read upRead up
- Exclude checks
UnusedPrivateMethod
Since: 0.2
Unused Private Method detects when a private method is declared but is unused.
Example
class Something
{
private function foo() {} // unused
}