lesterchan/wp-sweep

View on GitHub

Showing 326 of 326 total issues

The method sweep uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                        } else {
                            delete_comment_meta( $comment_id, $meta->meta_key );
                        }
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

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 sweep uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                        } else {
                            delete_post_meta( $post_id, $meta->meta_key );
                        }
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

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 sweep uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                        } else {
                            delete_term_meta( $term_id, $meta->meta_key );
                        }
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

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 sweep() has 267 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    public function sweep( $name ) {
        global $wpdb;

        $message = '';

Severity: Minor
Found in inc/class-wpsweep.php by phpmd

The method plugin_activation uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $this->plugin_activated();
        }
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

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

ajax_sweep accesses the super-global variable $_GET.
Open

    public function ajax_sweep() {
        // Verify referer and check permissions.
        if (
            empty( $_GET['sweep_name'] )
            || empty( $_GET['sweep_type'] )
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

ajax_sweep accesses the super-global variable $_GET.
Open

    public function ajax_sweep() {
        // Verify referer and check permissions.
        if (
            empty( $_GET['sweep_name'] )
            || empty( $_GET['sweep_type'] )
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

ajax_sweep_details accesses the super-global variable $_GET.
Open

    public function ajax_sweep_details() {
        // Verify referer and check permissions.
        if (
            empty( $_GET['sweep_name'] )
            || ! check_admin_referer( 'wp_sweep_details_' . $_GET['sweep_name'] )
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

The method total_count() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
Open

    public function total_count( $name ) {
        global $wpdb;

        $count = 0;

Severity: Minor
Found in inc/class-wpsweep.php by phpmd

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

ajax_sweep accesses the super-global variable $_GET.
Open

    public function ajax_sweep() {
        // Verify referer and check permissions.
        if (
            empty( $_GET['sweep_name'] )
            || empty( $_GET['sweep_type'] )
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

ajax_sweep accesses the super-global variable $_GET.
Open

    public function ajax_sweep() {
        // Verify referer and check permissions.
        if (
            empty( $_GET['sweep_name'] )
            || empty( $_GET['sweep_type'] )
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

ajax_sweep_details accesses the super-global variable $_GET.
Open

    public function ajax_sweep_details() {
        // Verify referer and check permissions.
        if (
            empty( $_GET['sweep_name'] )
            || ! check_admin_referer( 'wp_sweep_details_' . $_GET['sweep_name'] )
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

ajax_sweep accesses the super-global variable $_GET.
Open

    public function ajax_sweep() {
        // Verify referer and check permissions.
        if (
            empty( $_GET['sweep_name'] )
            || empty( $_GET['sweep_type'] )
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

ajax_sweep accesses the super-global variable $_GET.
Open

    public function ajax_sweep() {
        // Verify referer and check permissions.
        if (
            empty( $_GET['sweep_name'] )
            || empty( $_GET['sweep_type'] )
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

ajax_sweep accesses the super-global variable $_GET.
Open

    public function ajax_sweep() {
        // Verify referer and check permissions.
        if (
            empty( $_GET['sweep_name'] )
            || empty( $_GET['sweep_type'] )
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

ajax_sweep_details accesses the super-global variable $_GET.
Open

    public function ajax_sweep_details() {
        // Verify referer and check permissions.
        if (
            empty( $_GET['sweep_name'] )
            || ! check_admin_referer( 'wp_sweep_details_' . $_GET['sweep_name'] )
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

The method count() has a Cyclomatic Complexity of 24. The configured cyclomatic complexity threshold is 10.
Open

    public function count( $name ) {
        global $wpdb;

        $count = 0;

Severity: Minor
Found in inc/class-wpsweep.php by phpmd

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 ajax_sweep() has a Cyclomatic Complexity of 17. The configured cyclomatic complexity threshold is 10.
Open

    public function ajax_sweep() {
        // Verify referer and check permissions.
        if (
            empty( $_GET['sweep_name'] )
            || empty( $_GET['sweep_type'] )
Severity: Minor
Found in inc/class-wpsweep.php by phpmd

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 sweep() has a Cyclomatic Complexity of 66. The configured cyclomatic complexity threshold is 10.
Open

    public function sweep( $name ) {
        global $wpdb;

        $message = '';

Severity: Minor
Found in inc/class-wpsweep.php by phpmd

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 details() has a Cyclomatic Complexity of 28. The configured cyclomatic complexity threshold is 10.
Open

    public function details( $name ) {
        global $wpdb;

        $details = array();

Severity: Minor
Found in inc/class-wpsweep.php by phpmd

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

Severity
Category
Status
Source
Language