lesterchan/wp-sweep

View on GitHub

Showing 316 of 316 total issues

Function sweep has a Cognitive Complexity of 108 (exceeds 5 allowed). Consider refactoring.
Open

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

        $message = '';

Severity: Minor
Found in wp-sweep.php - About 2 days to fix

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 wp-sweep.php has 647 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * WP-Sweep wp-sweep.php
 *
 * @package wp-sweep
Severity: Major
Found in wp-sweep.php - About 1 day to fix

    File admin.php has 554 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * WP-Sweep admin.php
     *
     * @package wp-sweep
    Severity: Major
    Found in admin.php - About 1 day to fix

      Method sweep has 224 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function sweep( $name ) {
              global $wpdb;
      
              $message = '';
      
      
      Severity: Major
      Found in wp-sweep.php - About 1 day to fix

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                    case 'duplicated_commentmeta':
                        $query = $wpdb->get_results( $wpdb->prepare( "SELECT GROUP_CONCAT(meta_id ORDER BY meta_id DESC) AS ids, comment_id, COUNT(*) AS count FROM $wpdb->commentmeta GROUP BY comment_id, meta_key, meta_value HAVING count > %d", 1 ) );
                        if ( $query ) {
                            foreach ( $query as $meta ) {
                                $ids = array_map( 'intval', explode( ',', $meta->ids ) );
        Severity: Major
        Found in wp-sweep.php and 3 other locations - About 5 hrs to fix
        wp-sweep.php on lines 734..746
        wp-sweep.php on lines 760..772
        wp-sweep.php on lines 773..785

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 161.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                    case 'duplicated_postmeta':
                        $query = $wpdb->get_results( $wpdb->prepare( "SELECT GROUP_CONCAT(meta_id ORDER BY meta_id DESC) AS ids, post_id, COUNT(*) AS count FROM $wpdb->postmeta GROUP BY post_id, meta_key, meta_value HAVING count > %d", 1 ) );
                        if ( $query ) {
                            foreach ( $query as $meta ) {
                                $ids = array_map( 'intval', explode( ',', $meta->ids ) );
        Severity: Major
        Found in wp-sweep.php and 3 other locations - About 5 hrs to fix
        wp-sweep.php on lines 747..759
        wp-sweep.php on lines 760..772
        wp-sweep.php on lines 773..785

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 161.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                    case 'duplicated_termmeta':
                        $query = $wpdb->get_results( $wpdb->prepare( "SELECT GROUP_CONCAT(meta_id ORDER BY meta_id DESC) AS ids, term_id, COUNT(*) AS count FROM $wpdb->termmeta GROUP BY term_id, meta_key, meta_value HAVING count > %d", 1 ) );
                        if ( $query ) {
                            foreach ( $query as $meta ) {
                                $ids = array_map( 'intval', explode( ',', $meta->ids ) );
        Severity: Major
        Found in wp-sweep.php and 3 other locations - About 5 hrs to fix
        wp-sweep.php on lines 734..746
        wp-sweep.php on lines 747..759
        wp-sweep.php on lines 760..772

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 161.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                    case 'duplicated_usermeta':
                        $query = $wpdb->get_results( $wpdb->prepare( "SELECT GROUP_CONCAT(umeta_id ORDER BY umeta_id DESC) AS ids, user_id, COUNT(*) AS count FROM $wpdb->usermeta GROUP BY user_id, meta_key, meta_value HAVING count > %d", 1 ) );
                        if ( $query ) {
                            foreach ( $query as $meta ) {
                                $ids = array_map( 'intval', explode( ',', $meta->ids ) );
        Severity: Major
        Found in wp-sweep.php and 3 other locations - About 5 hrs to fix
        wp-sweep.php on lines 734..746
        wp-sweep.php on lines 747..759
        wp-sweep.php on lines 773..785

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 161.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function details has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

            public function details( $name ) {
                global $wpdb;
        
                $details = array();
        
        
        Severity: Minor
        Found in wp-sweep.php - About 4 hrs to fix

        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

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                    case 'orphan_usermeta':
                        $query = $wpdb->get_results( "SELECT user_id, meta_key FROM $wpdb->usermeta WHERE user_id NOT IN (SELECT ID FROM $wpdb->users)" );
                        if ( $query ) {
                            foreach ( $query as $meta ) {
                                $user_id = (int) $meta->user_id;
        Severity: Major
        Found in wp-sweep.php and 3 other locations - About 4 hrs to fix
        wp-sweep.php on lines 635..650
        wp-sweep.php on lines 651..666
        wp-sweep.php on lines 683..698

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 137.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                    case 'orphan_commentmeta':
                        $query = $wpdb->get_results( "SELECT comment_id, meta_key FROM $wpdb->commentmeta WHERE comment_id NOT IN (SELECT comment_ID FROM $wpdb->comments)" );
                        if ( $query ) {
                            foreach ( $query as $meta ) {
                                $comment_id = (int) $meta->comment_id;
        Severity: Major
        Found in wp-sweep.php and 3 other locations - About 4 hrs to fix
        wp-sweep.php on lines 635..650
        wp-sweep.php on lines 667..682
        wp-sweep.php on lines 683..698

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 137.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                    case 'orphan_termmeta':
                        $query = $wpdb->get_results( "SELECT term_id, meta_key FROM $wpdb->termmeta WHERE term_id NOT IN (SELECT term_id FROM $wpdb->terms)" );
                        if ( $query ) {
                            foreach ( $query as $meta ) {
                                $term_id = (int) $meta->term_id;
        Severity: Major
        Found in wp-sweep.php and 3 other locations - About 4 hrs to fix
        wp-sweep.php on lines 635..650
        wp-sweep.php on lines 651..666
        wp-sweep.php on lines 667..682

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 137.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 4 locations. Consider refactoring.
        Open

                    case 'orphan_postmeta':
                        $query = $wpdb->get_results( "SELECT post_id, meta_key FROM $wpdb->postmeta WHERE post_id NOT IN (SELECT ID FROM $wpdb->posts)" );
                        if ( $query ) {
                            foreach ( $query as $meta ) {
                                $post_id = (int) $meta->post_id;
        Severity: Major
        Found in wp-sweep.php and 3 other locations - About 4 hrs to fix
        wp-sweep.php on lines 651..666
        wp-sweep.php on lines 667..682
        wp-sweep.php on lines 683..698

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 137.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Function count has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

            public function count( $name ) {
                global $wpdb;
        
                $count = 0;
        
        
        Severity: Minor
        Found in wp-sweep.php - About 3 hrs to fix

        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 details has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function details( $name ) {
                global $wpdb;
        
                $details = array();
        
        
        Severity: Major
        Found in wp-sweep.php - About 3 hrs to fix

          The class WPSweep has an overall complexity of 190 which is very high. The configured complexity threshold is 50.
          Open

          class WPSweep {
              /**
               * Limit the number of items to show for sweep details
               *
               * @since 1.0.3
          Severity: Minor
          Found in wp-sweep.php by phpmd

          Since: PHPMD 0.2.5

          The Weighted Method Count (WMC) of a class is a good indicator of how much time and effort is required to modify and maintain this class. The WMC metric is defined as the sum of complexities of all methods declared in a class. A large number of methods also means that this class has a greater potential impact on derived classes.

          Example:

          class Foo {
                public function bar() {
                    if ($a == $b)  {
                        if ($a1 == $b1) {
                            fiddle();
                        } elseif ($a2 == $b2) {
                            fiddle();
                        } else {
                        }
                    }
                }
                public function baz() {
                    if ($a == $b) {
                        if ($a1 == $b1) {
                            fiddle();
                        } elseif ($a2 == $b2) {
                            fiddle();
                        } else {
                        }
                    }
                }
                // Several other complex methods
            }

          Source: http://phpmd.org/rules/codesize.txt

          The class WPSweep has 14 public methods. Consider refactoring WPSweep to keep number of public methods under 10.
          Open

          class WPSweep {
              /**
               * Limit the number of items to show for sweep details
               *
               * @since 1.0.3
          Severity: Minor
          Found in wp-sweep.php by phpmd

          Since: PHPMD 0.1

          A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects. By default it ignores methods starting with 'get' or 'set'.

          Source: http://phpmd.org/rules/codesize.txt

          Method count has 75 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function count( $name ) {
                  global $wpdb;
          
                  $count = 0;
          
          
          Severity: Major
          Found in wp-sweep.php - About 3 hrs to fix

            Method ajax_sweep has 66 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function ajax_sweep() {
                    if ( ! empty( $_GET['action'] )
                        && ! empty( $_GET['sweep_name'] )
                        && ! empty( $_GET['sweep_type'] )
                    ) {
            Severity: Major
            Found in wp-sweep.php - About 2 hrs to fix

              WPSweep has 21 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class WPSweep {
                  /**
                   * Limit the number of items to show for sweep details
                   *
                   * @since 1.0.3
              Severity: Minor
              Found in wp-sweep.php - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language